compile error ambiguous symbol for function call

The bool function pair value is assigned to boolean variable wpair. The compiler is giving me and error => pair:ambiguous symbol .




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Cardgame.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<time.h>

void shuffle(int[][13]);
void deal(const int[][13], int[][13]);
bool pair(const int[][13]);
int main()
{
	using namespace std;

	const char *suit[4] = { "Hearts", "Diamonds", "Clubs", "Spades" };
	const char *face[13] = 
	{ "Ace", "Deuce", "Three", "Four",
	"Five", "Six", "Seven", "Eight",
	"Nine", "Ten", "Jack", "Queen", "King" };
	int deck[4][13] = { 0 };
	int handone[4][13] = { 0 };
	bool wpair = false;

	srand(time(0));
	shuffle(deck);
	deal(deck,handone);
	wpair = pair(handone);
	cout << wpair << endl;

	cin.clear();
	cin.ignore(255, '/n');
	cin.get();

	return 0;
}

void shuffle(int wDeck[][13])
{
	int row, column;

	for (int card = 1; card <= 52; card++){
		do {
			row = rand() % 4;
			column = rand() % 13;
		} while (wDeck[row][column] != 0);
		wDeck[row][column] = card;
	}
}


void deal(const int wDeck[][13], int whandone[][13])
{

	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			switch (wDeck[i][j]){
			case 1 :
				whandone[i][j] = wDeck[i][j];
				break;
			case 2 :
				whandone[i][j] = wDeck[i][j];
				break;
			case 3 :
				whandone[i][j] = wDeck[i][j];
				break;
			case 4 :
				whandone[i][j] = wDeck[i][j];
				break;
			case 5 :
				whandone[i][j] = wDeck[i][j];
				break;
			default:
				break;

			}
		}
	}
}

bool pair(const int Whandone[][13])
{
	int cardcount[5] = { 0 };
	int hand[5] = { 0 };
	int paircnt = 0;

	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			switch (Whandone[i][j]){
			case 1:
				hand[0] = j;
				break;
			case 2:
				hand[1] = j;
				break;
			case 3:
				hand[2] = j;
				break;
			case 4:
				hand[3] = j;
				break;
			case 5:
				hand[4] = j;
				break;
			default:
				break;

			}
		}
	}

	for (int l = 0; l < 5; l++){
		for (int k = 0; k < 5; k++){
				if ((hand[l] == hand[k]) && (l == 0) && (l != k))
					++cardcount[0];
				if ((hand[l] == hand[k]) && (l == 1) && (l != k))
					++cardcount[1];
				if ((hand[l] == hand[k]) && (l == 2) && (l != k))
					++cardcount[2];
				if ((hand[l] == hand[k]) && (l == 3) && (l != k))
					++cardcount[3];
				if ((hand[l] == hand[k]) && (l == 4) && (l != k))
					++cardcount[4];
			}
		}

	for (int m = 0; m < 5; m++){
		if (cardcount[m] == 1)
			++paircnt;
	}

	if (paircnt == 1)
		return true;
	else
		return false;
}


 
Topic archived. No new replies allowed.