I have a class, WIDGET.
Code:
class WIDGET{
public:
WIDGET();//constructor
~WIDGET();//destructor
int uid();//returns UID
protected:
WIDGET* parent;//parent widget pointer
WIDGETINFO info;//widget data info stuff, yeah...
std::queue<EVENT> events;//Event queue
CRONOS* cronosInstance;//cronos instance
EVENTMANAGER* eventManInstance;//event manager instance
WIDGETMANAGER* widgetManInstance;//widget manager instance
static char* typeName;//widget type name
};
Code:
char* WIDGETMANAGER::typeName = "WIDGET";
And my derived BUTTON class.
Code:
class BUTTON:public WIDGET{
public:
BUTTON();
~BUTTON();
private:
protected:
};
Code:
char* BUTTON::typeName = "BUTTON";
However, as I'm sure you've already concluded this throws an error.
ISO C++ does not permit `WIDGET::typeName' to be defined as `BUTTON::typeName'
I guess I could stick this->typeName in the constructor for each derived class but I just thought keeping a static member would be easier and probably more efficient.