1)首先对于nontrivial的类(即有virtual method,vtable等),不管你写(自定义)或是没写(default)
copy control,constructor,destructor,编译器都会为你添加一些代码.
2)对于copy control,constructor,destructor:若是自定义写了它们,编译器就不会生成default版本
了,但1)的代码仍旧是给你添进去的. (所以有写在private:里面这种机制)
3)constructor,destructor有栈调用默认机制;copy constructor,operator=没有,所以此两者要显式
地去调用基类的copy constructor以及operator=.
class Test
{
public:
Test f1();
};
Test Test::f1()
{
Test result;
return result;
}
Test a;
Test b=a.f1(); //这里会有NRV(Named Return Value)优化
c++ object model p121-------data语义内存图片
static member function不能存取类内非static member,原因是它没有this指针
Test (Test::*p)() = &Test::f1() ; member function pointer