TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PHIL OHL
from: KURT KUZBA
date: 1998-04-09 02:46:00
subject: creating objects

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.