Hi guys,
i want to ask help for modular programming.
How can I let the secondary cpp file have access to the const int variable declared in the primary cpp file??
for instance:
/
primary.cpp
const int a = 55;
/
//secondary.cpp
for(int i=0; i<a; i++){
blah
blah
//
I want the function in secondary cpp to have access of const int a, which was declared in primary cpp.
cheers!!
Declare the variable in a .h file and include that file in both .cpp files
I have a compiler error saying "Redefinition of variables"?? what is that?
then you have declared the value somewhere in your project,,,
use this
|
extern the name of the value;
|
by the way they should have the same declaration..
Right
1 2 3 4 5
|
char Cvalue[6] ={0};
somewhere
extern char Cvalue[6];
|
Wrong
1 2 3 4 5
|
char Cvalue[6] ={0};
somewhere
extern char Cvalue[4];
|
Last edited on