All IT and Non IT Interview Questions, MCQs, Online Quiz Questions, Engineering VIVA Questions
Tuesday, 17 April 2012
Write a note about upcasting. | C++
Upcasting casts a pointer or a reference from a derived class to one of the base classes in the same hierarchy. Most upcasting is done by implicit conversion. The compiler performs a static type-check to ensure that the conversion from the derived class to the base class through a pointer is allowed, ^nd if it is not allowed, a compile-time error message appears./You use dynamic_cast for upcasting when you need to determine at runtime whether a pointer to a derived class really contains the address of an object of that class and at the same time, you can force the address into a pointer of one of the object's base classes.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment