Skills101
← All practice quizzes

Quiz: Memory and Smart Pointers

5 questionsNo time limitPass: 60%+10 XP on first pass

Manage memory the modern way: new and delete, RAII, unique_ptr and shared_ptr, the rule of three/five, copy vs move, and exception handling with try, catch and throw.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    Which smart pointer should be your default choice?

  2. Question 2

    What happens when you try to copy a unique_ptr?

  3. Question 3

    Which correctly frees memory from new int[50]?

  4. Question 4

    What does RAII guarantee?

  5. Question 5

    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;
    }