fork(1) download
  1. #include <stdio.h>
  2.  
  3. class Foo{};
  4.  
  5. class Bar : Foo {};
  6.  
  7. int main(void) {
  8. Bar b;
  9. Foo *fp = &b;
  10. dynamic_cast<Bar *>(fp);
  11. }
  12.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:9:13: error: 'Foo' is an inaccessible base of 'Bar'
  Foo *fp = &b;
             ^
prog.cpp:10:24: error: cannot dynamic_cast 'fp' (of type 'class Foo*') to type 'class Bar*' (source type is not polymorphic)
  dynamic_cast<Bar *>(fp);
                        ^
stdout
Standard output is empty