Class Question
Hi,
i have a little problem. Now i have some Classes like cWorld, cPlayer, cInput, cLog... ! i have put them in the files like cWorld.cpp/h, cPlayer.cpp/h... The Main File is main.cpp. New i implemented all classes in main.cpp like this
#include "CWorld.h"
#include "CPlayer.h"
cWorld world;
cPlayer pl;
Ok, that`s allright. Now my problem... For Example i want to use in cInput the world deklaration. but how can i implement something. I thought like an globals.h where all the deklaration are and every file can use the world and other files. But i don`t know how.
Thanks
Lutz Hören
P.S. sorry for my bad English, not my native language
psYchOtroW
look up ''extern'' i think that might have something to do with it, not sure i''m new.
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
I usually do something like that:
Now you have one global instance of CInput called Input. You can use it anywhere where input.h has been included.
///////////////////// input.h///////////////////class CInput {...};extern CInput Input;///////////////////// input.cpp///////////////////CInput Input;...
Now you have one global instance of CInput called Input. You can use it anywhere where input.h has been included.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement