c++ object initialization and constructor semantics

后端 未结 1 1309
抹茶落季
抹茶落季 2021-01-18 08:08

Is there a difference between the 2 initailizations of an object.

Object obj(constructor_arguments);

or

Object obj = Object         


        
相关标签:
1条回答
  • 2021-01-18 08:46

    Yes there is. The first is the syntax for direct initialization, the second is copy initialization.

    Theoretically, the second one calls the copy constructor, but this is subject to optimizations.

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