boost 中的 noncopyable
// boost
class noncopyable
{
protected:
noncopyable() {}
~noncopyable() {}
private:
noncopyable(const noncopyable&);
const noncopyable& operator = (const noncopyable&);
};
class test : public noncopyable
{
};
int main()
{
test a, b;
// test b(a);
// c = a;
}
這是通過繼承的方式來實(shí)現(xiàn)的 noncopy
也可以通過組合的方式
class noncopyable
{
public:
noncopyable() {}
~noncopyable() {}
private:
noncopyable(const noncopyable&);
const noncopyable& operator = (const noncopyable&);
}
class test
{
private:
noncopyable noncopyable_;
};
int main()
{
test a, c;
// test b(a);
// c = a;
}
http://www.shnenglu.com/luke/archive/2009/03/13/76411.html
http://ebenzhang.blogbus.com/tag/noncopyable/
http://hi.baidu.com/jrckkyy/blog/item/e6b241de1645735f95ee37de.html
http://hi.baidu.com/jrckkyy/home
http://blog.csdn.net/alai04/article/details/577798
http://www.boost.org/doc/libs/1_47_0/boost/noncopyable.hpp
posted on 2011-07-23 22:07
unixfy 閱讀(445)
評(píng)論(0) 編輯 收藏 引用