C++ Constructors have no return type. Just exactly why?

前端 未结 8 870
孤独总比滥情好
孤独总比滥情好 2021-01-04 14:00

I\'ve Googled this and read many posts, but there are so many different answers that all make logical sense that I was wondering if an expert on the topic could demystify th

8条回答
  •  無奈伤痛
    2021-01-04 14:19

    Constructors implicitly return an instance of the class itself. It will be contradicting if it were designed to return something and the programmer returned something completely different other than the class itself. Basically the syntax would be confusing.

提交回复
热议问题