我有一个与继承有关的问题。
我声明一个类,然后声明一个子类,如下所示
`Producer::Producer(Pool<string>* p, string id) {
mPool = p; // protected members
mId = id;
}
ProduceCond::ProduceCond(Pool<string>* p, string id) {
Producer(p, id);
}
class Producer{
}
class ProduceCond : public Producer, public ThreadSubject {
}
`
虽然我在子构造函数中调用了正确的父构造函数,但我收到一个错误
ProduceCond.cpp:10:52: error: no matching function for call to ‘Producer::Producer()’
有人能告诉我为什么我会收到这个错误,尽管我使用了正确的父构造函数格式吗?