C++基准有没有规定"="到底调用ctor还是copy ctor还是operator=
C++标准有没有规定到底调用ctor还是copy ctor还是operator?我有下面的小程序,测试函数Create()的返回
C++标准有没有规定"="到底调用ctor还是copy ctor还是operator=?
我有下面的小程序,测试函数Create()的返回值,赋值给G g1=Create()的时候,到底是调用了G的ctor还是copy ctor还是operator=.
比如
Programmers new to C++ often have two common misunderstandings:
That a default constructor is synthesized for every class that does not define one
That the compiler-synthesized default constructor provides explicit default initializers for each data member declared within the class
As you have seen, neither of these is true.
尤其是第一句。
很多人觉得 类没声明构造函数,编译器就会生成一个。其实不是的!!!!
具体的 请 阅读 Inside the c++ object model 2.1 节