TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PHIL OHL
from: DARIN MCBRIDE
date: 1998-04-07 18:26:00
subject: creating objects

 PO> I know how to make an object the normal way:
 PO> player player1();
Well, no.  That declares a function, returning a player, called player1, that 
takes no arguements.  :-)
player player1;
 PO> but I am trying to create a certain user defined number of objects.
 PO> Like:
 PO> cout<<"Number of players ";
 PO> cin>>n;
// in here:
player players = new player[n]; // n players.
 PO> for(x=0; x {
 PO> cout<<"Player Name ";
 PO> cin.getline(name,20);
 PO> /*now i want to create am object here with the name of 'name' but i
 PO> don't know how*/
Actually, you'll need to use the array, and then have a function to set the 
name.
players[x].setName(name);
 PO> }
Hope this helps!
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)

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™.