#include <iostream> using namespace std; class A{ public: virtual ~A() {} }; class B: public A{ }; int main(){ A * a = new A(); try{ B * b = dynamic_cast<B *>(a); }catch(...){ } return 0; }
std::bad_cast
b
a
Login in to like
Login in to comment
or Read more about C++ Quizzes
Login in to like
Login in to comment