Question OOP-CLS-0045
MediumWhat is the output of this code?
#include <iostream>
using namespace std;
class A {
public:
static int n;
A() { n++; }
};
int A::n = 0;
int main() {
A x, y;
A *p = new A();
A arr[2];
cout << A::n;
delete p;
}
- A.
5
- B.
2
- C.
3
- D.
4
Sign up free to see the answer and a step-by-step explanation.