Consider the following example:
class B { … };
class D : public B { … };
void f()
{
B* pb = new D; // unclear but ok
B* pb2 = new B;
D* pd = dynamic_cast(pb); // ok: pb actually points to a D
…
D* pd2 = dynamic_cast(pb2); //error: pb2 points to a B, not a D
// pd2 == NULL
…
}
This type of conversion is called a “downcast” because it moves a pointer down a class hierarchy, from a given class to a class derived from it.
Categories
Tags
about answer Answers Anyone asked Auctions Best career CCNA Certification COMPUTER Cycle debugging Development exam find from good help Inheritance Interview JAVA know latest life microsoft need Oracle Please Programming question Questions should Software Some someone Tell Testing there these think this want Winform Would