Is it true that a default constructor is synthesized for every class that does not define one?

后端 未结 6 662
感情败类
感情败类 2020-12-28 11:09

If the class doesn\'t have the constructor, will the compiler make one default constructor for it ?

Programmers new to C++ often have two common misu

6条回答
  •  半阙折子戏
    2020-12-28 11:14

    A default constructor is synthesized for every class that does not define one if:

    • The code using the class needs one & only if
    • There is no other constructor explicitly defined for the class by you.

提交回复
热议问题