fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct A {virtual void foo(){}};
  6. struct B {virtual void foo(){}};
  7.  
  8. int main() {
  9. A *a = new A();
  10. B *b = new B();
  11. A *aPtr1 = dynamic_cast<A*>(b);
  12. cout << (aPtr1 == 0) << endl;
  13. A *aPtr2 = dynamic_cast<A*>(a);
  14. cout << (aPtr2 == 0) << endl;
  15. delete a;
  16. delete b;
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 2812KB
stdin
Standard input is empty
stdout
1
0