I am using a for loop to instantiate a number of player objects. Each object is is a different player in the game, and for the user's sake, I need to be able to know which player object is being referred to as the turns change during the game, therefore I need to be able to give each player object a name, such as Bruce, Alfred, or Harvey. I assumed I could use a setter to let the user input the players name when the constructor is called, but I can't seem to figure out how to do this. Can someone point me in the right direction? Below is what I have currently, but the cin in the setter does not work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Player //player class to control chips and turns
{
public:
staticint chips;
string name = "";
Player() //player object constructor
{
chips = 3;
name();
}
string name()
{
cin >> name;
return name;
}