// Prevent copy construction and assignment for a class
#define REFERENCEOBJECT(className) \
private: \
className(const className& other); \
className& operator = (const className& other);
class TestCase{
REFERENCEOBJECT(TestCase)
}
// Prevent copy construction and assignment for a class
#define REFERENCEOBJECT(className) \
private: \
className(const className& other); \
className& operator = (const className& other);
class TestCase{
REFERENCEOBJECT(TestCase)
}
本文介绍了一种防止C++中类被拷贝构造和赋值的方法,通过定义私有的拷贝构造函数和赋值操作符,并且不提供实现来阻止这些操作的发生。
350

被折叠的 条评论
为什么被折叠?



