Consider the Grand, Superb, and Magnificent classes defined in this chapter. Suppose pg is a type Grand

Question:

Consider the Grand, Superb, and Magnificent classes defined in this chapter. Suppose pg is a type Grand * pointer that is assigned the address of an object of one of these three classes and that ps is a type Superb * pointer.What is the difference in how the following two code samples behave?
if (ps = dynamic_cast(pg))
ps->say(); // sample #1

if (typeid(*pg) == typeid(Superb))
(Superb *) pg)->say(); // sample #2

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

C++ Primer Plus

ISBN: 9780321776402

6th Edition

Authors: Stephen Prata

Question Posted: