PO> I am trying to create a certain user defined number of
PO> objects. Like:
PO> cout<<"Number of players ";
PO> cin>>n;
PO> for(x=0; x {
PO> cout<<"Player Name ";
PO> cin.getline(name,20);
PO> /*
PO> now i want to create am object here with the name of
PO> 'name' but i don't know how
PO> */
PO> }
I don't think you can actually do that,and I don't know why
you would want to. The names given to variables have
meanings only in source and in source debugging. In code
compiled for release, all those labels are absent.
If you desire a means to have the name of the player
associated with the object, then include a name variable
within the object itself.
cout " << flush;
cin >> nPlayers;
PlayerObjects *cPlayers = new *PlayerObjects[nPlayers];
for(int n = 0; n < nPlayers; n++)
{
char szPlayerName[20];
cout "
<< flush;
cin.getline(szPlayerName, 20);
cPlayers[n] = PlayerObjects(szPlayerName);
}
---
> ] Boredom is the fear that your fun is catching up to you.....
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
|