Hi
I'm a newbie to C++
I've been trying to find out the best way of initialising a static (private) data member of a class, which is an STL container (Multimap).
I know one can initialise 'simple' static member data types in the definition, by just applying the constructor. e.g. int myClass::myInt(4).
However, when it comes to initialising a static data member which is an STL container, I couldn't think of an easy way.
My solution was to inherit from the STL Container class, defining my own class, and have the constructor for my STL-derived class do it's initialisation (using 'insert' to add some constant mappings).
I am wary of ineriting from the STL, so I have two questions:
1) Is inheriting from the STL classes good, bad or neither?
2) Is there a better way of initialising complex static data members?
I suppose I could have a separate 'initialise' method, but it seems a bit inelegant, given that the class should be ready to use as soon as it's defined.
Best Regards
--Anthony
I'm a newbie to C++
I've been trying to find out the best way of initialising a static (private) data member of a class, which is an STL container (Multimap).
I know one can initialise 'simple' static member data types in the definition, by just applying the constructor. e.g. int myClass::myInt(4).
However, when it comes to initialising a static data member which is an STL container, I couldn't think of an easy way.
My solution was to inherit from the STL Container class, defining my own class, and have the constructor for my STL-derived class do it's initialisation (using 'insert' to add some constant mappings).
I am wary of ineriting from the STL, so I have two questions:
1) Is inheriting from the STL classes good, bad or neither?
2) Is there a better way of initialising complex static data members?
I suppose I could have a separate 'initialise' method, but it seems a bit inelegant, given that the class should be ready to use as soon as it's defined.
Best Regards
--Anthony