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

Re: Problems with g++



Ivan:
>       I'm using g++ egcs-2.91.60 and I've had some problems with
> inclusions of a header file. For example, if I declare a variable
> in example.h and #includes it in example.c++ and in example2.c++
> (these two files reference that variable and #include that header
> file), I get an error message like this:

You seem to be using C++ like you maybe did with C.
I'd like to advise against that.
In a OO language, globals are bad.

If you really need an object that is accessible by more than one
module, and that can't be passed as a function parameter,
then try to build a class/routine encapsulating it, and that has
static variables.

If you want to know how OO programmers do it, search the net or
deja.com for 'singleton'.  But please don't use C++ as you would
do it with C --- heck you can even do C without globals, and it's
much cleaner.

ralf (Sather acolyte)
-- 
http://home.t-online.de/home/Ralf_W.Stephan/
It's not a cat, it's a tree posing as a cat.


Reply to: