#include <iostream>#include <iomanip> using namespace std; struct Widget{ int widget;}; struct Button : public Widget{ int button;}; int main(){ Widget* w = new Widget; Button* b = dynamic_cast<Button*>(w);}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:20:37: error: cannot dynamic_cast ‘w’ (of type ‘struct Widget*’) to type ‘struct Button*’ (source type is not polymorphic) Button* b = dynamic_cast<Button*>(w); ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!