C++ FNoncopyable Class

C++ 中为了避免被不正确引用,经常会有不允许 copy 的对象,下面是 FNoncopyable 的 Class 模板

/**
 * utility template for a class that should not be copyable.
 * Derive from this class to make your class non-copyable
 */
class FNoncopyable
{
protected:
    // ensure the class cannot be constructed directly
    FNoncopyable() {}
    // the class should not be used polymorphically
    ~FNoncopyable() {}
private:
    FNoncopyable(const FNoncopyable&);
    FNoncopyable& operator=(const FNoncopyable&);
};
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。