Question OOP-CLS-0016
HardWhat is the output of this code?
#include <iostream>
using namespace std;
class A {
public:
int v;
A(int x) : v(x) {}
};
int main() {
A a(1);
A b = a;
b.v = 2;
cout << a.v << " " << b.v;
return 0;
}
- A.
1 2
- B.
Error
- C.
1 1
- D.
2 2
Sign up free to see the answer and a step-by-step explanation.