Which special member function is automatically called when an object is created in C++?

Options

  • A. Destructor
  • B. Constructor
  • C. Operator Function
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Constructor

Detailed Explanation

Explanation: A constructor is a special member function that is automatically invoked when an object is created. It initializes the object and has the same name as its class in C++.