[amp_mcq option1=”One semicolon” option2=”One colon” option3=”Two colons” option4=”One space” correct=”option1″]
The correct answer is: A constructor initialization list is preceded by one colon.
A constructor initialization list is a list of expressions that are used to initialize the members of a class when an object of that class is created. The syntax for a constructor initialization list is as follows:
“`
class MyClass {
MyClass(int x) : x(x) {}
int x;
};
“`
In this example, the constructor initialization list is preceded by a colon (:). The expression x(x) is used to initialize the member x of the class MyClass.
The following options are incorrect:
- Option B: A constructor initialization list is not preceded by a colon.
- Option C: A constructor initialization list is not preceded by two colons.
- Option D: A constructor initialization list is not preceded by a space.