Default constructor c++

前端 未结 4 2064
南笙
南笙 2021-01-07 04:19

I am trying to understand how default constructor (provided by the compiler if you do not write one) versus your own default constructor works.

So for example I wrot

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-07 05:19

    A n();
    

    could be parsed as an object definition with an empty initializer or a function declaration.

    The language standard specifies that the ambiguity is always resolved in favour of the function declaration (§8.5.8).

    So n is a function without arguments returning an A.

提交回复
热议问题