#include <iostream> using namespace std; class A{ public: virtual ~A() {} }; class B: public A{ }; int main(){ A 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