Checking if a pointer points to a particular class C++

Viewed 22768

Possible Duplicate:
Finding the type of an object in C++

I have a question with checking pointers to see if they conform to a particular derived class and take necessary action.

Lets say I currently have 2 derived classes DerivedClass1 and DerivedClass2 and the base class BaseClass. I would like to check the following action.

Ptr<BaseClass> ptr;

if (ptr points to DerivedClass1) { action1 } else { action2 }

How do I check for ptr points to a particular DerivedClass?

3 Answers
Related