f**********t 发帖数: 1001 | 1 写blackJack, 定义Suit之后怎么着都通不过。求大牛指点。
class Card {
public:
enum Suit { CLUBS = 1, SPADE = 2, DIAMOND = 3, HEART = 4 };
private:
int value_;
Suit suit_;
public:
Card(int value, Suit suit) {
value_ = value;
suit_ = suit;
}
int Value() {
return value_;
}
Suit Suit() {
return suit_;
}
};
class BlackJackCard : public Card {
public:
BlackJackCard(int value, Suit suit):Card(value, suit) {
} //这里出错:function Card::Suit is not a type name
int Value() {
int r = Card::Value();
if (r == 1) return 11;
if (r < 10) return r;
return 10;
}
bool isAce() {
return Card::Value() == 1;
}
}; | k***g 发帖数: 166 | | k****5 发帖数: 546 | 3 two Card::Suit symbol, it's confusing.
rename one of them or use "enum Suit" instead of "Suit" | h*********n 发帖数: 39 | 4 typedef enum Suit{…} Suit; |
|