What is the main purpose of the constructor?

a) Begin the execution of class
b) Include the macros for the program
c) Establish the class invariant
d) Terminate the program

1 thought on “ What is the main purpose of the constructor?”

  1. c
    Explanation: 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.

Leave a Comment