Defining a function

I am making a program (for practice and fun) that takes baseball players and information about each respective player and stores it in a struct then writes it to an output file. I want to handle the adding of the players with a function called addPlayer(). In general, should this function have "parameters"? Meaning addplayer(parameter a, parameter b,...) (sorry if that wasn't the right term. Correct me if I'm wrong please.) I had to post this with my phone so I can't really upload any code right now and I know that makes this a more difficult question to answer that way. :-/ sorry and thank you in advance. Any input is appreciated.
I would suggest that you have the following:

class Player

class Team

The Player class just holds data for a single player, and the Team class holds data for all the players in the team. The Team class would then have the addPalyer function taking an argument as const Player. The controlling routine would then use an instance of Team as follows to add a new player:

 
myTeam->addPlayer(new Player());


HTH
Yes, addPlayer() should have parameter. The parameter are the information you want to add.
Yap. You can consider following lets say;

addPlayer( char* name , int age , int jersy )
Last edited on
Ok! Thanks a lot!
Topic archived. No new replies allowed.