Tak prezentuje się mój jakże zaawansowany kod do tej pory
klasa reprezentująca kartę, chyba nie trzeba nic tłumaczyć
Kod:
class Card
{
private:
string suit;
string face;
public:
Card(){}
Card(string f, string s){
face = f;
suit = s;
}
string getCard(){
return (this->face + " of " + this->suit + "s");
}
};
Kod:
class Deck : Card
{
private:
Card deck[52];
public:
Deck(){
Card *aceh = new Card("ace", "heart");
deck[0] = *aceh;
}
};
Kod:
int main(void){
Deck *deckOfCards = new Deck();
cout << deckOfCards[0].getCard;
system("PAUSE");
}
1>card.cpp(7): error C2011: 'Card' : 'class' type redefinition
1>card.cpp(7) : see declaration of 'Card'
1>deck.cpp(7): error C2504: 'Card' : base class undefined
1>deck.cpp(12): error C2027: use of undefined type 'Card'
1> card.cpp(7) : see declaration of 'Card'
1>card.cpp(7) : see declaration of 'Card'
1>deck.cpp(7): error C2504: 'Card' : base class undefined
1>deck.cpp(12): error C2027: use of undefined type 'Card'
1> card.cpp(7) : see declaration of 'Card'
Zakładki