Hi!
I'm having problem with using RTTI when compiling with gcc 4.0.2.
Is there any flags I should use when compiling? (tried -frtti)
Read somewhere that I should include <typeinfo> in the headers... but in which headers? All headers
in the project?
I thought that it was turned in as default. But when I use dynamic_cast it lets me cast to wathever...
take this for example:
class Thing ( base class, polymorphic )
class Contour class Polygon ( subclasses of Thing )
class Thing ( base class, polymorphic )
class Contour class Polygon ( subclasses of Thing )
To copy to clipboard, switch view to plain text mode
Thing *thing = new Contour ( );
/* This should work */
Contour *con = dynamic_cast<Contour*) ( thing );
if ( con == NULL )
std::cout<<"con==NULL"<<std::endl;
/* this should return a NULL pointer */
Polygon *pol = dynamic_cast<Polygon*) ( thing );
if ( pol == NULL )
std::cout<<"pol==NULL"<<std::endl;
Thing *thing = new Contour ( );
/* This should work */
Contour *con = dynamic_cast<Contour*) ( thing );
if ( con == NULL )
std::cout<<"con==NULL"<<std::endl;
/* this should return a NULL pointer */
Polygon *pol = dynamic_cast<Polygon*) ( thing );
if ( pol == NULL )
std::cout<<"pol==NULL"<<std::endl;
To copy to clipboard, switch view to plain text mode
No of the two returned casts are NULL. From what I understand, the second cast should be NULL since I try to cast a Contour to a Polygon.
This kind of things just makes me sad...
pir
Bookmarks