In C++, a constructor must have:
-
A
the same name as the class
Correct answer
-
B
the name 'init'
-
C
a return type of void
-
D
the keyword constructor
Correct answer
A. the same name as the class
12 views
Explanation
A constructor carries the class name and has no return type.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ