-
What is the main purpose of the constructor?
-
- Include the macros for the program
- Establish the class invariant
- Begin the execution of class
- All of above
- None of these
Correct Option: B
The purpose of a constructor is to establish the class invariant. To do that, it often needs to acquire system resources or in general perform an operation that may fail.