fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class X { };
  5. class Y : public X { };
  6. class Z : public X { };
  7.  
  8. int main() {
  9. Z *z = new Z();
  10. Y *y = new Y();
  11. z = y;
  12. cout << (z == y);
  13. return 0;
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:11:11: error: cannot convert 'Y*' to 'Z*' in assignment
         z = y;
           ^
prog.cpp:12:23: error: comparison between distinct pointer types 'Z*' and 'Y*' lacks a cast
         cout << (z == y);
                       ^
stdout
Standard output is empty