I have a player class. In the class I have a hand of size three, which is of type card. Card is another class. I am trying to access the private data members of hand through class, but inside the player class. This is the error I get:
scat.cpp: In member function ‘void player::setHand(card*)’:
scat.cpp:117:10: error: request for member ‘cardCopy’ in
‘((player*)this)->player::hand’, which is of pointer
type ‘card*’ (maybe you meant to use ‘->’ ?)hand.cardCopy(c);
#include <iostream>
using namespace std;
class card{
char *suit;
char *rank;
int cvalue;
char *location;
public:
card::cardCopy(card *c);
};
class player{
card *hand;
public:
player::setHand(card *c);
};
void card::cardCopy(card *c)
{
strcopy(rank, (*c).rank);
strcopy(suit, (*c).suit);
strcopy(location, (*c).location);
cvalue = (*c).cvalue;
}
player::player()
{
name = new char[20];
hand = new card[3];
}
void player::setHand(card*c)
{
hand.cardCopy(c);
}
I dont understand why i cant access the function cardCopy like this..hand is a card type!!!