I keep getting a LNK2019 linker error but cannot figure out how to fix it.
1>LNK2019.obj : error LNK2019: unresolved external symbol "public: __thiscall myClass::myClass(void)" (??0myClass@@QAE@XZ) referenced in function _wmain
1>LNK2019.obj : error LNK2019: unresolved external symbol "public: void __thiscall myClass::doSomething(void)" (?doSomething@myClass@@QAEXXZ) referenced in function _wmain
LNK2019.cpp:
The error doesn't happen when I change myClass a1 to myCalss a1(), but when I do I can't call a1.doSomething() as it expects the expression to have a class type?
#include "stdafx.h"
#include "myClass.h"
int _tmain(int argc, _TCHAR* argv[])
{
myClass a1;
a1.doSomething();
return 0;
}
myClass.h
#pragma once
#include "example.h"
class myClass
{
example memberExample;
public:
myClass();
void doSomething();
};
myClass.cpp
#include "myClass.h"
myClass::myClass() : memberExample(23, 67)
{
// Do stuff
}
void myClass::doSomething()
{
// Do stuff
}
example.h
#pragma once
class example
{
int a, b;
public:
example(int, int);
};
example.cpp
#include "example.h"
example::example(int x, int y)
{
a = x;
b = y;
}
I cannot make changes to example.h or example.cpp and the member functions of myClass need to be able to see memberExample.
Also it all seemed to work in a single .cpp file, from what I can tell the #include's are fine?
(Sorry if this question is really common, I tried Googling but didn't know what to search for)