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?
- Yes
- No
- 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;
- A constructor is called for
s. Then, as assignment operation is called forother. - A constructor is called for
s, and then a copy constructor is called to createother. - A constructor is called for
s, and then another regular constructor is called forother.
More questions available in the full version of the book.