Maps and derived classes

Hello,
I have a map which takes pointers to elements of a class A. B and C are both derived from A. C has some additional functions that it doesn't derive from A. How can I access these functions after retrieving an element from the map which is of type C?
The only way I can think of is to declare them in class A as pure virtual functions.
You need to do 2 things:

1. compile your code with RTTI enabled.
2. use dynamic_cast on the retrieved element, such as:

A *pA = {retrieve an element from map};
C *pC = dynamic_cast<C *>(pA);
if (pC != NULL)
pC->additionalFunction();
Topic archived. No new replies allowed.