class Team
{
string Color;
int NumberOfPlayers;
public:
Team();
Team(string a);
~Team();
Player TeamsPlayers[11];
int Wins;
//Getters| Setters
void setColor(string Color);
void setWins(int Wins);
string getColor();
int getNumberOfPlayers();
int getWins();
void status(Team ob);
void AddPlayers(Team ob);
};
void Team::status(Team ob)
{
for(int i=0; i<counter; ++i)
cout<< (ob.TeamsPlayers[i]).getName() <<endl;
}
int main()
{
Player p;
Team::AddPlayers(p); // this function works
}
So basically I want to print the name of the players(these are objects from class Player) within the array of objects which is an instance variable of the class Team.(First time asking a question here please dont be too harsh")
Team::AddPlayers(p); // this function worksI doubt it. method is not static, you should probably haveTeam team; team.AddPlayer(p);instead.