class noncopyable
{
protected:
noncopyable(){};
~noncopyable(){};
private:
noncopyable(const noncopyable&){}; 将复制构造和复制复制私有化,从它派生的类编译器就不会自动加上了
const noncopyable& operator=(const noncopyable&){};
};
struct CA: public noncopyable
{
void fa(){std::cout<<"mm"<<endl;}
};
CA c1 , c2;
CA c3(c1); //这里会编译出错
//#include <boost/utility.hpp>
struct CA: boost::noncopyable //这里使用boost库里面的noncopyable
{
void fa(){std::cout<<"mm"<<endl;}
};