Two Two And Silence
#include <iostream>
#include <memory>
struct Node {
std::shared_ptr<Node> next;
std::shared_ptr<Node> prev;
~Node() { std::cout << "~"; }
};
int main() {
auto a = std::make_shared<Node>();
auto b = std::make_shared<Node>();
a->next = b;
b->prev = a;
std::cout << a.use_count() << b.use_count(); // (1)
a.reset();
b.reset();
std::cout << "|end";
}
What is the exact output?
Sign in to answer questions and track your progress
Sign In