C++ default constructor

前端 未结 4 1315
無奈伤痛
無奈伤痛 2021-01-17 19:09

If we say that the default constructor is that constructor without parameters, can we also say the the constructor created by the compiler is also a defau

4条回答
  •  死守一世寂寞
    2021-01-17 19:29

    The default constructor is a constructor that may be called without arguments. So this is either a constructor that has no arguments, or a constructor whose arguments all have default values.

    But yes, the compiler generates a default constructor if you don't provide any other constructors.

    Recommended reading: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.4.

提交回复
热议问题