Last Updated on May 3, 2022 by Admin 2
What is the output of the following snippet?
#include <iostream> using namespace std; class N { public: float x; N() { x = 0.0; } N(float a) {x = a; } N(N &n) { x = n.x; } N &operator<<(N &y) { return *new N(x * 10); } }; int main() { N a(2.0),b(4.0); N c = a << 1; cout << c.x; return 0; }
0
- Compilation fails
2
1