Home » C++ Programming » Exception Handling » Question
  1. What is the main purpose of the constructor?
    1. Include the macros for the program
    2. Establish the class invariant
    3. Begin the execution of class
    4. All of above
    5. 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.



Your comments will be displayed only after manual approval.