Base class to subclass conversion
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
A cast will do the trick (
pBase
is a pointer to the base class). The fastest way if you're sure it's safe:static_cast<Dervied*>(pBase);
The safest way (runtime checked):dynamic_cast<Dervied*>(pBase);
You could use Boost's polymorphic_downcast[^] for a solution that usesdynamic_cast
in debug builds andstatic_cast
in release builds.Steve