Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Oct 10, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using dynamic_cast Properly

Programmers who use dynamic_cast sometime discover that their applications suffer from mysterious crashes although seemingly, they are bug free. In most cases, the reason is that they forgot to turn on RTTI support when building the application. For RTTI to operate, the compiler must generate additional code and data in the object file. Most compilers don't generate this code by default because of its incurred performance overhead. Consequently, any attempt to use dynamic_cast causes a runtime crash because the implementation can't locate the necessary runtime type information to perform the cast. Therefore, remember always to turn on your compiler's RTTI toggle when you build an application that uses RTTI features such as dynamic_cast and typeid.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date