Skip to content
Quiz · Memory and Smart Pointers · lesson 9 of 12

Quiz — shared_ptr

What does the program print?

C++
#include <iostream>
#include <memory>

int main() {
    auto a = std::make_shared<int>(5);
    auto b = a;
    {
        auto c = b;
        std::cout << a.use_count() << ' ';
    }
    std::cout << a.use_count() << '\n';
}