class BaseClass
{
enum
{
Type = -1,
ParentType = -1,
};
virtual unsigned int GetType() { return Type; }
virtual unsigned int GetParentType() { return ParentType; }
};
class ClassA : public BaseClass
{
enum
{
Type = 1,
ParentType = BaseClass::Type,
};
virtual unsigned int GetType() { return Type; }
virtual unsigned int GetParentType() { return ParentType; }
};
class ClassB : public ClassA
{
enum
{
Type = 2,
ParentType = ClassA::Type,
};
virtual unsigned int GetType() { return Type; }
virtual unsigned int GetParentType() { return ParentType; }
};
custom RTTI - using the preprocessor
i have my own run time type info. system which goes something like this:
now, i want to change this to use macros, and i want the preprocessor to generate the Type = xxx
I saw a thread on here once about a preprocessor macro that would increment a value each time it was used, but i forgot what it was.
__COUNTER__ is almost certainly reset for each compilation unit though, so you'll probably need to define all of your IDs in one unit (Or header and make sure that __COUNTER__ isn't used elsewhere).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement