'NotificationCenter' 构造函数必须显式初始化成员 'receiverModel',它没有默认构造函数
这个错误提示是因为在创建'NotificationCenter'类的对象时,'receiverModel'成员变量没有默认构造函数,需要显式地进行初始化。解决方法如下:
- 在'NotificationCenter'类的构造函数中初始化'receiverModel'对象。
例如:
class NotificationCenter {
public:
NotificationCenter() : receiverModel(ReceiverModel()) {}
private:
ReceiverModel receiverModel;
};
- 给'receiverModel'添加默认构造函数。
例如:
class ReceiverModel {
public:
ReceiverModel() {}
};
以上两种方法都可以解决这个错误提示。
原文地址: https://www.cveoy.top/t/topic/mS4w 著作权归作者所有。请勿转载和采集!