What is the main purpose of the constructor?
A. Begin the execution of the class
B. Include the macros for the program
C. Establish the class invariant
D. None of the mentioned
Answer:A
What is the main purpose of the constructor?
A. Begin the execution of the class B. Include the macros for the program C. Establish the class invariant D. None of the mentioned
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.