Tag Archives: 编译器

C++编译器自动生成的基本函数

1 编译器自动生成的基本函数 C++编译器会在开发人员没有声明下列函数的时候,声明编译器自己的版本。 class Empty{} 等效于下面的声明 class Empty{ public: Empty(); //缺省构造函数 Empty(const Empty& rhs); //拷贝构造函数 ~Empty(); //析构函数 Empty & operator=(const Empty& rhs); //赋值运算符 Empty & operator&(); //取址运算符 const Empty * operator&() const; } 下面是编译器的参考实现 inline Empty::Empty() {} inline Empty::~Empty() {} … Continue reading

2 Comments

Filed under C++, 技术