Complete the code to declare a constructor for the class.
class MyClass { public: [1]() { // Constructor body } };
The constructor has the same name as the class. Here, MyClass is the correct constructor name.
Complete the code to declare a destructor for the class.
class MyClass { public: [1]() { // Destructor body } };
The destructor has the class name preceded by a tilde (~). Here, ~MyClass is the correct destructor name.
Fix the error in the constructor definition to properly initialize the member variable.
class MyClass { int value; public: MyClass(int v) { value [1] v; } };
To assign the parameter v to the member variable value, use the assignment operator =.
Fill both blanks to use an initializer list to initialize the member variable.
class MyClass { int value; public: MyClass(int v) [1] value[2] v) {} };
The initializer list starts with a colon (:), and member variables are initialized with parentheses ().
Complete the code to define a copy constructor that copies the member variable.
class MyClass { int value; public: MyClass(const MyClass& other) : value( [1] ) {} };
The copy constructor uses an initializer list starting with a colon (:), initializes value with parentheses, and copies from other.value.