Is it possible to acces the data from an object of Class1 using a function from Class2?

The full question would be:
Is it possible to acces the data from an object(or multiple objects) of Class1 using a function from Class2 that also needs to acces some parameters from Class 2?

long story short, here is the code I am having trouble with:
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
class card {
public:
	unsigned char r;
	unsigned char s;
	bool state;
	friend class player;
};

class player{
public:
	int a[11]; 
	int setSuma(){

		for(int i = 1; i <= 11; i++){
			if(a[i] == 11 || a[i] == 12 || a[i] == 13){
				suma += a[i]+1;
			} else if(a[i] == 1) {
				suma += 11;
			}else {
				suma += a[i];
			}
		}
		return suma;
	}
	void showSum();
private:
	int suma;
};

card deck[52] = {
			{ ACE, SPD }, { 2, SPD }, { 3, SPD }, { 4, SPD }, { 5, SPD }, { 6, SPD }, { 7, SPD },
			{ 8, SPD }, { 9, SPD }, { 10, SPD }, { JACK, SPD }, { QUEEN, SPD }, { KING, SPD },
			{ 1, HRT }, { 2, HRT }, { 3, HRT }, { 4, HRT }, { 5, HRT }, { 6, HRT }, { 7, HRT },
			{ 8, HRT }, { 9, HRT }, { 10, HRT }, { JACK, HRT }, { QUEEN, HRT }, { KING, HRT },
			{ 1, DIA }, { 2, DIA }, { 3, DIA }, { 4, DIA }, { 5, DIA }, { 6, DIA }, { 7, DIA },
			{ 8, DIA }, { 9, DIA }, { 10, DIA }, { JACK, DIA }, { QUEEN, DIA }, { KING, DIA },
			{ 1, CLB }, { 2, CLB }, { 3, CLB }, { 4, CLB }, { 5, CLB }, { 6, CLB }, { 7, CLB },
			{ 8, CLB }, { 9, CLB }, { 10, CLB }, { JACK, CLB }, { QUEEN, CLB }, { KING, CLB }
	};

And the function that I am trying to create is something like this:
1
2
3
4
5
6
void player::showSum(){
		for(int i = 1; i <= 11 ; i++){
			cout << deck[a[i]] << " ";
		}
		cout << setSuma();
	}

I need it to access the data from the objects deck[52] of class card, but it also needs some data from the class player;
Thank you in advance!!!
Topic archived. No new replies allowed.