在C++11标准中的描述是:
=default: it means that you want to use the compiler-generated version of that function, so you don't need to specify a body.
=delete: it means that you don't want the compiler to generate that function automatically.
解释一下:
(1)针对于构造函数,析构函数,拷贝构造函数,拷贝赋值运算符.
(2)函数声明后面加了 =default; 表示按系统的默认函数定义来,不用单独写函数定义了.
(3)函数声明后面加了 =delete; 表示强制取消系统的默认定义.
例如:
class Member
{
public:
Member() =default;
};
可以正常调用Member的默认构造函数,而不用专门写构造函数定义.
而去掉=default; 则会报错error: undefined symbol.
增加=delete; 则会报错error: call to deleted constructor
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- efsc.cn 版权所有 赣ICP备2024042792号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务