Make a variabele available to all cpp files
ATM I have a file named main.cpp, which includes the header main.h
I want to divide main.cpp in different parts now, so I made different cpp files which all store a few functions. 1 for text, 1 for initializing everything, etc.
the problem is, I need a variabele in text.cpp now which I made in main.h, which is included in main.cpp
I want the variabele to be available in the other cpp file too. How do I do this? It would be even better if there was a way to include all the variabeles in all the files if that''s possible...
I tried including the main.h file in the other documents, but this doesn''t work because it tries to re-make the variabeles...
Or am I doing something wrong?
use the "extern" keyword. for example:
// main.cppint iSomething;..............// text.cppextern int iSomething..............
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement