When running the following code i get a big compile error:
Linking...
main.obj : error LNK2001: unresolved external symbol "public: __thiscall debug::debug(int)" (??0debug@@QAE@H@Z)
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Class definiation saved as : class.h
#ifndef CLASS_H
#define CLASS_H
class debug
{
public:
debug(int a = 77);
int getbug();
private:
int x;
};
#endif
class functions saved as: debug.cpp
#include <iostream>
using namespace std;
#include "class.h"
debug::debug(a)
{
a = x;
}
int debug::getbug()
{
return x;
}
main: saved as main.cpp
#include <iostream>
using namespace std;
#include "class.h"
int main()
{
debug d1(100);
return 0;
}
if you've noticed in main thats theres an include.h , if I change it to include the .cpp instead it works 100% but thats not considered good programming. So I'm hoping someone will let me know whats what?