Advertisement

Multiple CPP in Project

Started by March 11, 2001 03:03 PM
1 comment, last by PCI 23 years, 8 months ago
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.[email=red@deadpenguin.org]red@deadpenguin.org[/email]www.deadpenguin.org
Advertisement
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..

This topic is closed to new replies.

Advertisement