constructor for NotificationCenter must explicitly initialize the member receiverModel which does not have a default constructor应该怎么解决
这个错误提示是因为在创建NotificationCenter类的对象时,receiverModel成员变量没有默认构造函数,需要显式地进行初始化。解决方法如下:
1.在NotificationCenter类的构造函数中初始化receiverModel对象。
例如:
class NotificationCenter {
public:
NotificationCenter() : receiverModel(ReceiverModel()) {}
private:
ReceiverModel receiverModel;
};
2.给receiverModel添加默认构造函数。
例如:
class ReceiverModel {
public:
ReceiverModel() {}
};
以上两种方法都可以解决这个错误提示。
原文地址: http://www.cveoy.top/t/topic/bp2V 著作权归作者所有。请勿转载和采集!