What is the output of the following snippet?

Last Updated on May 3, 2022 by Admin 2

What is the output of the following snippet?

#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;
}
  • 0
  • -1
  • 1
  • Compilation fails
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments