1.

What does dynamic_cast return after successful type casting?(a) Address of object which is converted(b) Address of object that is used for conversion(c) Address of object that is mentioned in the syntax(d) Doesn’t return any addressI had been asked this question during an interview for a job.My question comes from Downcasting topic in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

The correct answer is (a) Address of OBJECT which is CONVERTED

For EXPLANATION: The address of the object which is converted is RETURNED by the dynamic_cast operator. This is done to safely convert the subtype to supertype. This ensures the proper assignment and conversion from ONE type to another.



Discussion

No Comment Found

Related InterviewSolutions