Hi, here my program I have a class wrestler and a class team. The class wrestler as you can see has ability point and weight etc...
The class team has wrestlers and points.
This program creates 20 different teams with a random number of wrestlers with a random ability and random weight.
What I'm trying to do is to access to the wrestlers that are part of team 1.
class wrestler{
public:
wrestler(){}
~wrestler(){}
void setid(int i){id = i;}
int getid(){return id;}
void setweight(int w){weight = w;}
int getweight(){return weight;}
void setability(int a){ability = a;}
int getability(){return ability;}
void display(){cout<<"Player number "<<id<<" weights "<<weight<<" and it has an ability score of "<<ability<<endl;}
friendclass team;
private:
int id;
int weight;
int ability;
int weightclass;
int wins;
int losses;
};
class team{
public:
team (){}
~team (){}
void setpl(int p){players = p;}
int getpl(){return players;}
void setp(int o){points = o;}
int getp(){return points;}
void display(int g){cout<<"There are "<<players<<" players in the Team number "<<g<<endl<<endl;}
friendclass wrestler;
private:
int points;
int players;
wrestler w []; ///how do i access it
};
I understand that the ability and weight are private but I can't understand how to access them.
You can only access private members in the team file. You can make a function in your team file that has access to wrestler w[]; and make a function call to the function in main.