[C++-sig] [Py++] boost::shared_ptr casting

Nat Goodspeed nat at lindenlab.com
Sun Mar 21 22:28:05 CET 2010

peoro wrote:

> Ok, it does work as expected if class Base has got at least one virtual member:
> ...What if I cannot add a virtual function to the class Base?

If your C++ base class has no virtual methods, even pure C++ can't 
dynamic_cast<> it.

Put differently -- you've been asking Python to determine the runtime 
type of a class for which C++ maintains no runtime type. It's the 
presence of at least one virtual method that forces C++ to start 
tracking the runtime type of a class hierarchy.

More information about the Cplusplus-sig mailing list