Question OOP-CLS-0065
HardWhat is the output of this code?
#include <iostream>
using namespace std;
class T {
public:
static int live;
T() { live++; }
T(const T&) { live++; }
~T() { live--; }
};
int T::live = 0;
T make() { T t; return t; }
int main() {
T a;
{
T b = a;
T c;
cout << T::live << " ";
}
T d = make();
cout << T::live;
}
- A.
3 2
- B.
3 3
- C.
2 2
- D.
3 4
Sign up free to see the answer and a step-by-step explanation.