rendered paste bodyI am trying to overload the < operator and failing. My code is below and the compiler error is below that.
//BEGIN card.h
#include <string>
using namespace std;
class card
{
public:
card();
card(int cardFace, string cardSuit);
bool operator<(const card& rhs) const;
int getFace();
string getSuit();
private:
int face;
string suit;
};
//END card.h
//BEGIN card.cc
#include "card.h"
using namespace std;
card::card()
{
}
card::card(int cardFace, string cardSuit)
{
face = cardFace;
suit = cardSuit;
}
bool card::operator<(const card& rhs) const
{
return this->face < rhs->face;
}
int card::getFace()
{
return face;
}
string card::getSuit()
{
return suit;
}
//END card.cc
//BEGIN build error
smack@smacktop:~/Desktop/net_cards$ make
g++ -c card.cc
card.cc: In member function bool card::operator<(const card&) const:
card.cc:18: error: base operand of -> has non-pointer type const card
make: *** [card.o] Error 1