class Empty {}; //其实等价于 class Empty { public: Empty() { ... } //default constructor Empty(const Empty &rhs) { ... } //copy constructor ~Empty() { ... } //destructor Empty& operator=(const Empty &rhs) { ... } //copy assignment };
class A { public: private: A(const A &rhs); //只有声明 A& operator=(const A &rhs); };
class Uncopyable { public: Uncopyable() {} ~Uncopyable() {} private: Uncopyable(const Uncopyable&); Uncopyable& operator=(const Uncopyable&); }; class B : private Uncopyable { };
原文地址:http://blog.csdn.net/shoulinjun/article/details/35991441