7. Quiz on Constructors

Congratulations!

You’ve just completed the section on the basics and constructors.

Here’s a quick quiz. Try answering the following questions, and then we will continue our journey :)

1. Can a constructor have a different name than the class name?
  1. Yes
  2. No
  3. Yes, but it can be only named self()
2. What operations are called in the following code? Pick one option.
std::string s { "Hello World" };
std::string other = s;
  1. A constructor is called for s. Then, as assignment operation is called for other.
  2. A constructor is called for s, and then a copy constructor is called to create other.
  3. A constructor is called for s, and then another regular constructor is called for other.

More questions available in the full version of the book.