Question OOP-ENC-0064
HardWhat is the output of this code?
#include <iostream>
using namespace std;
class Box {
int w = 0;
friend class Inspector;
};
class Inspector {
public:
static void set(Box &b, int v) { b.w = v; }
static int get(const Box &b) { return b.w; }
};
int main() {
Box b;
Inspector::set(b, 9);
cout << Inspector::get(b);
}
- A.
9
- B.
Garbage value
- C.
0
- D.
Compilation error
Sign up free to see the answer and a step-by-step explanation.