Topic: static class members
Author: betty@ssv.den.mmc.com (Betty Glass)
Date: Tue, 9 Nov 1993 23:30:08 GMT Raw View
We are having trouble compiling c++ code which includes static
(private) members in the class definition. We are using the
GNU 2.2 version of g++ and gcc. Is there some compile flag we
are missing. I can't believe that gnu c++ has overlooked this
feature.
Any ideas, suggestions, help?
Betty Glass
Author: betty@ssvkimber.NoSubdomain.NoDomain (Betty Glass)
Date: Wed, 10 Nov 1993 16:49:24 GMT Raw View
The problem I posted yesterday obviously didn't contain enough information,
so let me try once more. The code comes from some extended InterViews
graphics code.
There is a graphics class which includes static private members.
The abbreviated header file looks like
-------------------------------------------------
class Brush;
class BrushMap;
class GraphicsKit {
public:
GraphicsKit();
~GraphicsKit();
...
GraphicsKit methods
...
private:
const Brush* _brush;
static BrushMap* _brushmap;
};
-----------------------------------------------------------------------
where class Brush and BrushMap are defined in seperate header files and
BrushMap actually incorporates a Brush object in its class definition.
The order of include files is
#include brush.h
#include brushmap.h
#include grahicskit.h
-----------------------------------------------------------------------
We compile all the graphics objects into a library using GNU g++ Version 2.3.
The library is made with no problems. But when examining the library we
find all the Brush references and objects but not the BrushMap stuff.
So when this library is linked with the main code we come up with
Unresolved Symbols -- BrushMap.
My question is then, does GNU c++ handle static variables in header files?
Could there be special compile flags that we're missing?
Author: kocher@us-es.sel.de (Hartmut Kocher)
Date: Wed, 10 Nov 93 17:42:09 GMT Raw View
In article <1993Nov10.164924.20245@den.mmc.com>, betty@ssvkimber.NoSubdomain.NoDomain (Betty Glass) writes:
> The problem I posted yesterday obviously didn't contain enough information,
> so let me try once more. The code comes from some extended InterViews
> graphics code.
>
> There is a graphics class which includes static private members.
> The abbreviated header file looks like
> -------------------------------------------------
> class Brush;
> class BrushMap;
>
> class GraphicsKit {
> public:
> GraphicsKit();
> ~GraphicsKit();
> ...
> GraphicsKit methods
> ...
> private:
> const Brush* _brush;
>
> static BrushMap* _brushmap;
> };
> -----------------------------------------------------------------------
> where class Brush and BrushMap are defined in seperate header files and
[stuff deleted]
>
> My question is then, does GNU c++ handle static variables in header files?
> Could there be special compile flags that we're missing?
Your class only contains a declaration of a static BrushMap pointer.
Did you also DEFINE it somewhere?
In some source file you should have
BrushMap GraphicsKit::_brushmap = 0; // or similar...
otherwise it's not defined!
Hope this helps
Hartmut
--
+==============================|==============================+
| Hartmut Kocher | |
| Technical Consultant | All opinions expressed here |
| Rational GmbH | are my own. |
| Rosenstrasse 7 | |
| 82049 Pullach im Isartal | I know you guessed it, |
| Germany | but it keeps my lawyer happy.|
| Email: hwk@rational.com | |
+==============================|==============================+