【发布时间】:2015-05-31 22:59:07
【问题描述】:
假设我有:
class Human {
string choice;
public:
Human(string);
};
class Computer {
string compChoice;
public:
Computer(string);
};
class Refree : public Human, public Computer {
public:
string FindWinner();
};
int main() {
Human* H1 = new Human("name");
Computer* C1 = new Computer("AI");
Refree* R1 = new Refree();
}
此代码无法编译:
In function 'int main()':
error: use of deleted function 'Refree::Refree()'
note: 'Refree::Refree()' is implicitly deleted because the default definition would be ill-formed:
error: no matching function for call to 'Human::Human()'
note: candidates are:
note: Human::Human(std::string)
note: candidate expects 1 argument, 0 provided
为什么会失败,如何构造指向Refree 的指针?
【问题讨论】:
标签: c++ class pointers multiple-inheritance