Search This Blog

Thursday, November 25, 2010

TypeID for derived classes of a common base class

Programmer Question

Hey guys,



I'm attempting to implement some mechanism in C++ whereby all classes derived from a common base class are assigned a unique "class ID". For example:



class BaseClass  
{
//...
public: unsigned int GetID( void );
//...
};
class DerivedClass : public BaseClass
{
}


Class DerivedClass, and all other children of BaseClass, should be able to return unique identifiers without any additional code added to DerivedClass...C++ is making this rather difficult for me, however. Any ideas would be appreciated.



Thanks in advance!
---Dan



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails