Advertisement

Globals between files

Started by October 24, 2001 06:47 AM
1 comment, last by Drazgal 23 years, 4 months ago
Strangle enough this has never come up in my programming til now. Is there anyway I can use globals between .cpp files? For example, I have a file with multiplayer game logic and another file with singleplayer logic and a last file called main where everything is controlled from. Is there anyway I can get the globals decalred in main to work in the functions decalred in the gamelogic files or do I just have to bite the bullet and pass everything through with pointers/references? http://kickme.to/BallisticPrograms
  /* Alpha.cpp */unsigned int AlphaVal;/* Alpha.h */#ifndef INC_ALPHA_HEADER#define INC_ALPHA_HEADERextern unsigned int AlphaVal;#endif/* Beta.cpp */#include "Alpha.h"int Something(void) {  AlphaVal = 5;}  

Works with functions too.

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
Thanks!

http://kickme.to/BallisticPrograms

This topic is closed to new replies.

Advertisement