what's wrong with this

Need to change the int to char?

cpp file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void Card::swap ( int &a, int &b )
{
int temp = a;
a = b;
b = temp;
}

void Card::shuffle()
{
srand(time(0));
for(int i = 0; i<51; i++)
{
int ranNo = rand() % 52;
swap(cards[i],cards[ranNo]);
}



}

hpp file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Card
{

public:
Card();
~Card();

void swap(int&,int&);
void shuffle();
string ToStr();
void combine();

private:
CardType cards[52];
};


In member function 'void Card::shuffle()':|
error: no matching function for call to Card::swap(CardType&, CardType&)'|

note: candidates are: void Card::swap(int&, int&)|
error: prototype for 'std::string Card::ToStr(char)' does not match any in class 'Card'
Your shuffle function calls swap with inputs of type CardType &, so references to CardTypes. Swap is however declared to take references to int. I guess you have to decide whether you want your swap function to take integers or cardTypes.
changed the int in swap function to CardType.
compile success.
Thanks fugu :)
Topic archived. No new replies allowed.