#include <iostream> using namespace std; class X { }; class Y : public X { }; class Z : public X { }; int main() { Z *z = new Z(); Y *y = new Y(); z = y; cout << (z == y); return 0; }
Standard input is empty
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); ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!