← Quiz: Memory and Smart Pointers: all 10 questions
Quiz: Memory and Smart Pointers · Question 5 of 10
What does this print? (code)
What does this print?
#include <iostream>
#include <memory>
using namespace std;
int main() {
auto a = make_shared<int>(5);
auto b = a;
auto c = b;
cout << a.use_count();
return 0;
}
- A.1
- B.2
- C.3
- D.5
Answer & explanation
Correct answer: 3
Three shared_ptrs own the same int.
Can you get the rest right without peeking?
Take the timed Quiz: Memory and Smart Pointers quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →