I have a class CMain that creates the irrlicht device, I need to be able to pass that device to another class thats created within CMain. I remember doing this last time I used irrlicht I thought it had something to do with abstracts but a helpfull gentlemen on IRC told me how i should be going about it...but I can't get it to work. If someone can even tell me what this concept is called so I can google for it, I've read so much stuff about classes tonite trying to figure this out, but its never mentioned in the stuff I found.
Actual error:
Cmain.obj : error LNK2019: unresolved external symbol "public: __thiscall CProject::CProject(class CMain *)" (??0CProject@@QAE@PAVCmain@@@Z) referenced in function "public: unsigned short __thiscall Cmain::Go(void)" (?Go@Cmain@@QAEGXZ)
C:\Documents and Settings\madoc\My Documents\Visual Studio 2005\Projects\GUI_DEV\Debug\GUI_DEV.exe : fatal error LNK1120: 1 unresolved externals
Example code (stripped to code that matters):
And instead of CProject I used CWhatever to make it easier to read
Code: Select all
// Main.cpp
#include "CMain.h"
int main(void) {
CMain main;
main.go();
}
Code: Select all
//CMain.h
class Cwhatever;
class CMain {
private:
IrrlichtDevice *device;
public:
void go(); // This creates the device and assigns it
IrrlichtDevice *getDevice();
};
Code: Select all
//CMain.cpp
#include "CWhatever.h"
void CMain::go() {
CWhatever thingy(this);
}
Code: Select all
//CWhatever.h
class CMain;
class CWhatever {
public:
CWhatever(Cmain *myparent);
};
Code: Select all
//CWhatever.cpp
#include "CMain.h"
CWhatever::CWhatever(Cmain *myparent) {
myparent->getDevice()->DoSomeThing();
}