- #1
- 4,652
- 38
Hi. I am working on an assignment writing the implementation for a class of playing cards.
http://www.pic.ucla.edu/~nathan/cgi-bin/moin.cgi/la1#head-111d7fc9df65f327018fa94234ab0b23c0857e98
Here is the header file that we were provided.
I have written two constructors and the getRank() and getSuit() member functions so far.
I am working in Visual C++ 6 and getting some errors:
error C2143: syntax error : missing ';' before 'tag::id'
error C2501: 'Rank' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
and all reference the
Rank Card::getRank() const
line in my card.cpp file.
Am I missing something obvious? Thanks!
http://www.pic.ucla.edu/~nathan/cgi-bin/moin.cgi/la1#head-111d7fc9df65f327018fa94234ab0b23c0857e98
Here is the header file that we were provided.
Code:
//filename card.h
#ifndef CARD_H
#define CARD_H
#include <iostream>
namespace pic10b{
class Card{
friend std::ostream& operator<<(std::ostream& os, const Card& c);
public:
enum Rank {TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE};
enum Suit {CLUB, DIAMOND, HEART, SPADE};
Card(){rank = TWO; suit = CLUB;};
Card( Rank r, Suit s);
Card( const Card& c );
Rank getRank() const;
Suit getSuit() const;
bool isFaceCard() const;
std::string toString() const;
bool operator<(const Card& c) const;
bool operator>(const Card& c) const;
bool operator<=(const Card& c) const;
bool operator>=(const Card& c) const;
bool operator==(const Card& c) const;
bool operator!=(const Card& c) const;
private:
std::string abbr() const;
Rank rank;
Suit suit;
};
}
#endif
Code:
//filename card.cpp
#include "card.h"
using namespace pic10b;
using namespace std;
Card::Card(Rank r, Suit s)
{
rank = r;
suit = s;
}
Card::Card(const Card& c )
{
rank = c.getRank();
suit = c.getSuit();
}
Rank Card::getRank() const //errors reference this line
{
return rank;
}
Suit Card::getSuit() const
{
return suit;
}
error C2143: syntax error : missing ';' before 'tag::id'
error C2501: 'Rank' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
and all reference the
Rank Card::getRank() const
line in my card.cpp file.
Am I missing something obvious? Thanks!
Last edited by a moderator: