kloffy
11th October 2007, 22:34
Do I need to recompile qmake with the exceptions, rtti and stl flags to get dynamic_cast to work with QT? I'm using Visual C++ 2005 and the /GR flag is enabled (by default).
I'm asking because have implemented a simple Composite Pattern (http://en.wikipedia.org/wiki/Composite_pattern) and I need to find out whether the Component is a Leaf or a Composite. This is what I would like to do:
try
{
Leaf* leaf = dynamic_cast<Leaf*>(component);
//A Leaf
}
catch (std::bad_cast e)
{
//Not a Leaf
}
However, in practice the exception is never thrown and the program dies because of memory access violations.
I'm asking because have implemented a simple Composite Pattern (http://en.wikipedia.org/wiki/Composite_pattern) and I need to find out whether the Component is a Leaf or a Composite. This is what I would like to do:
try
{
Leaf* leaf = dynamic_cast<Leaf*>(component);
//A Leaf
}
catch (std::bad_cast e)
{
//Not a Leaf
}
However, in practice the exception is never thrown and the program dies because of memory access violations.