Question OOP-CTOR-0064
HardWhat is the output of this code?
#include <iostream>
#include <memory>
using namespace std;
#include <memory>
class N {
public:
int v;
N(int x) : v(x) { cout << "N" << v; }
~N() { cout << "~N" << v; }
};
int main() {
auto p = make_shared<N>(1);
{
auto q = p;
cout << p.use_count();
}
cout << p.use_count();
p.reset();
cout << "end";
}
- A.
N11~N1end
- B.
N121end~N1
- C.
Sign up free to see the answer and a step-by-step explanation.