Is it really necessary for the constructor to have the same name as the class?
Is it really necessary for the constructor to have the same name as the class?
Yes, it is. Language requires this by convention. It might not be, but it's like this.
Documentation . Also . Microsoft Documentation . If the specification were openly published I would post it here, but the excerpt from item 12.1 would be:
Constructors do not have names. A special declarator syntax is used to declare or define the constructor.
So this is the syntax adopted by convention, although formally it does not have an official name.