August 2012
Intermediate to advanced
976 pages
30h 17m
English
typeid OperatorThe second operator provided for RTTI is the typeid operator. The typeid operator allows a program to ask of an expression: What type is your object?
Exercises Section 19.2.1
Exercise 19.3: Given the following class hierarchy in which each class defines a public default constructor and virtual destructor:
class A { /* . . . */ };class B : public A { /* . . . */ };class C : public B { /* . . . */ };class D : public B, public A { /* . . . */ };
which, if any, of the following dynamic_casts fail?
(a) A *pa = new C; B *pb = dynamic_cast< B* >(pa);(b) B *pb = new B; C *pc = dynamic_cast< C* >(pb);(c) A *pa = new D; B *pb = dynamic_cast< B* >(pa);
Exercise 19.4: Using the classes defined in the first exercise, ...
Read now
Unlock full access