Re: dynamic_cast to another base class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Aseem,

> Class C doesn' t have virtual functions BUT has a virtual destructor.

A virtual destructor fulfills the requirement for the class to have a
virtual function table, so that there is a place (off the virtual function
table) to hold the object's type information.

And, hence, that the class is a polymorphic class, which is required to use
the dynamic_cast.

> Can you point me to some literature which explains as to why
> dynamic_cast requires virtual functions ?

p409 (section 15.4.1) in Stroustrup's C++ programming Language (Special
edition) mentions the requirement that the pointer's type be polymorphic.

Sincerely,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux