In C++, is a constructor with only default arguments a default constructor?

后端 未结 1 1471
孤独总比滥情好
孤独总比滥情好 2020-12-10 13:34

In the following code:

struct Foo
{
    Foo(int x=0);
};

Does the constructor count as a default constructor?

相关标签:
1条回答
  • 2020-12-10 13:57

    C++98 §12.1/5 (emphasis mine):

    A default constructor for a class X is a constructor of X that can be called without an argument. If there is no user-declared constructor for class X, a default constructor is implicitly declared.

    So yes, it does count as a default constructor. See also.

    0 讨论(0)
提交回复
热议问题