【发布时间】:2020-05-20 20:52:31
【问题描述】:
我猜我遇到了继承问题。
这是头文件中的类:
class Single : public Combination{
public:
Single(Card* card);
};
这是在 .cpp 文件中初始化的组合:
Combination::Combination(Card** cards, CombinationType type, int numberOfCards){
this->cards = cards;
this->numberOfCards = numberOfCards;
this->type = type;
}
这是 .cpp 文件中的 Single 类,是给我错误的类:
Single::Single(Card* card){
cards = new Card*[1];
cards[0] = card;
Combination(cards, SINGLE, 1); //<- this context
}
错误提示:'Combination::Combination(Card**, CombinationType, int)' 在此上下文中受到保护,但是从头文件中 Single 不能访问 Combination?
编辑:感谢你们快速而翔实的回复!不幸的是,我只能勾选你们中的一个,但我真的很感激!
【问题讨论】:
标签: c++