Skills101
← All practice quizzes

Quiz: Move Semantics and rvalue References

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Copying a big object duplicates all its data; moving just hands over the pointer. Learn lvalues and rvalues, rvalue references, std::move, the move constructor and move assignment, noexcept and the rule of five.

Log in to take the quiz

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

  1. Question 1

    Which of these is an rvalue?

  2. Question 2

    What does std::move(x) actually do?

  3. Question 3

    What does this print?

    #include <iostream>
    #include <string>
    #include <utility>
    using namespace std;
    void f(const string &) { cout << "L"; }
    void f(string &&) { cout << "R"; }
    int main() {
        string s = "x";
        f(s);
        f(s + "y");
        f(move(s));
        f(s);
        return 0;
    }
    
  4. Question 4

    What should a move constructor do with the source object's pointer?

  5. Question 5

    Why should move constructors be marked noexcept?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →