Self-test questions

  1. The Rule of Three states that if you define your own destructor for a class, you should also define:

    a. Your own copy constructor

    b. Your own assignment operator

    c. Both a and b

    d. Either a or b

  2. Assuming the class String has both copy and move constructors, which of the following does not invoke a move constructor:

    a. String s1(getName());

    b. String s2(s1);

    c. String s2(std::move(s1));

    d. String s3("Hello");

  3. The purpose of std::move function is to:

    a. Move contents of its argument out

    b. Create an lvalue reference from an rvalue reference

    c. Create an xvalue from an lvalue expression

    d. Swap contents of its argument with another object

  4. In which of the following cases does Return Value Optimization apply?:

    a. return std::string("Hello");

    b. ...

Get Learning Boost C++ Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.