析构函数
拷贝构造函数
赋值运算符(operator=)
取址运算符(operator&)(一对,一个非const的,一个const的)
当然,所有这些只有当被需要才会产生。比如你定义了一个类,但从来定义过该类的对象,也没使用过该类型的函数参数,那么基本啥也不会产生。在比如你从来没有进行过该类型对象之间的赋值,那么operator=不会被产生。
最后那一对取址运算符是用争议的, 我记得以前是有一个贴讨论这个的,
据说跟具体的编译器相关, 有的生成, 有的不生成, 只有前四个
原来也是看了《Effective C++》上面的总结,没有细想想,也没有查阅一下资料,刚刚查了C++98年标准(ISO/IEC 14882),至少在“Special Member Function”一节中并未提到operator&。而仅仅提到了其它四个:
原文抄录如下:
The default constructor(12.1), copy constructor and copy assignment operator(12.8), and destructor(12.4) are special member functions. The implementation will implicitly declare these member functions for a class type when the program does not explicitly declare them, except as noted in 12.1. The implementation will implicitly define them if they are used, as specified in 12.1, 12.4 and 12.8. ……