fork(3) download
  1. struct A {};
  2.  
  3. struct B : A {};
  4.  
  5. int main()
  6. {
  7. A* a = new B();
  8.  
  9. B* b = dynamic_cast<B*>(a);
  10. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9:30: error: cannot dynamic_cast ‘a’ (of type ‘struct A*’) to type ‘struct B*’ (source type is not polymorphic)
     B* b = dynamic_cast<B*>(a);
                              ^
stdout
Standard output is empty