You are correct about leagueTeams being responsible for storing the team names. However, the call that leagueTeams makes, set_team_name(teamName), stores the name in the variable fteamName:
1 2 3 4
|
void set_team_name(string teamName)
{
fteamName = teamName; //the team name assigned to fteamName
}
|
If you want to access the team's name, the get_team_name function should access fteamName. This will be accessing the data that is stored in the cteams object.
To get back all of the teams, (print to screen or whatnot), you will need to access each cteam object that you stored data to with the call to add_league_teams. Currently, 'cteams returns' is only one of those teams, in your cleague class, you iterate through 10 league teams (leagueTeams[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10]) and add data (team name) to them. The statement
cout << returns.get_team_name(0) << endl;
only accesses the team's name stored in the returns object.
It might make more sense to do the adding of team names outside of the cleague class, instead of creating an array of objects leagueTeams in that class.