Multiple CPP in Project
I have my main program stuff in my main CPP and put a function in a second cpp. Now I made a header file with the function prototype and included it in the main cpp. But I can''t share variables between the 2 cpp''s.WHY!. Is there any way around this?
say you have a global int myvar; in your first.cpp, and want to use in in your second add extern int myvar;
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
__________________graham "red" reeves.[email=red@deadpenguin.org]red@deadpenguin.org[/email]www.deadpenguin.org
March 14, 2001 11:47 AM
you could also declare all variables as extern in the header file..
for one large project I worked on, I created a global.h that declared ALL global variables in the project as extern..after including it in all src files I could access ANY global variables from anywhere in the code..
for one large project I worked on, I created a global.h that declared ALL global variables in the project as extern..after including it in all src files I could access ANY global variables from anywhere in the code..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement