Implicit return type of a class constructor is :
2016
Implicit return type of a class constructor is :
- A.
not of class type itself
- B.
class type itself
- C.
a destructor of class type
- D.
a destructor not of class type
Attempted by 131 students.
Show answer & explanation
Correct answer: B
Answer: class type itself
Explanation: Constructors do not declare an explicit return type. Their purpose is to initialize and create an object, and the result of construction is an instance of the class. Therefore, the implicit type associated with construction corresponds to the class type itself.
Constructors cannot explicitly return values or specify a return type.
The object produced by construction is of the class type, so that is effectively the implicit return type.
A destructor is a separate mechanism for cleanup and is not returned by a constructor.
Short example: Declaring an object like MyClass obj; constructs an object of type MyClass — the constructed value is of the class type.