首页 > 技术文章 > c++禁用拷贝构造函数和赋值函数

rohens-hbg 2019-12-28 10:13 原文

 
 
// A macro to disallow the copy constructor and operator= functions
#ifndef DISALLOW_COPY_AND_ASSIGN
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
TypeName& operator=(const TypeName&) = delete;
#endif
 
节选自 https://github.com/PlatformLab/NanoLog.git
代码中: <<common.h>>

推荐阅读