[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problems with g++

>    What can I do to declare all the global variables in the
> header file and avoid the redefinition of them, when the
> header is #included by more than one .c++ file? 

You need to put in .h file something like

extern int global; 

this way it would only be a declaration, not a definition. 

Then, *one* of the .c++ file would have to contain definition:

int global;

And this variable will be accessible from any other .c++ file that #include
the header file with "extern" declaration.

Alex Y.
 _( )_
(     (o___           +-------------------------------------------+
 |      _ 7           |            Alexander Yukhimets            |
  \    (")            |       http://pages.nyu.edu/~aqy6633/      |
  /     \ \           +-------------------------------------------+

Reply to: