Skip to main content
GameDev.net gamedev.net
🔒 Locked

Class Question

Started by PsYchOtroW Oct 26, 2000 at 10:30 AM 1 replies 450+ views
Original Post
PsYchOtroW
PsYchOtroW
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, thats 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 dont know how. Thanks Lutz Hören P.S. sorry for my bad English, not my native language
psYchOtroW
Scooter
Scooter
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.
BitMaster
BitMaster
I usually do something like that:
    
///////////////////

// 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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.