Effective C++:条款06:若不想使用编译器自动生成的函数,就该明确拒绝 (Explicitly disallow the use of complier-generated functions you do not want.)
为驳回编译器自动(暗自)提供的机能,可将相应的成员函数声明为private并且不予实现。使用像Uncopyable这样的base class也是一种做法。
class Uncopyable
{
protected:
Uncopyable(){}
~Uncopyable(){}
private:
Uncopyable(const Uncopyable&);
Uncopyable& operator=(const Uncopyable&);
};
---------------------------------------------------------------------------
You got a dream
You gotta protect it
People can't do something themselves
They wanna tell you you can do it
If you want something
Go get it
You got a dream
You gotta protect it
People can't do something themselves
They wanna tell you you can do it
If you want something
Go get it