delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/26/05:29:40

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C++ Class Help
Date: Tue, 25 Mar 1997 22:32:59 -0800
Organization: Alcyone Systems
Lines: 26
Message-ID: <3338C31B.6277480E@alcyone.com>
References: <199703252129 DOT VAA02177 AT post DOT dialin DOT co DOT uk>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Lee Simons wrote:

> I would like to be able to do a:
> 
> data[0](100, 99)
> 
> sort of thing.  Where 100 is the skill as shown in the other example, and
> 99 is the speed.

Create a constructor for class Player that takes two ints, i.e.
Player::Player(int, int).  Then declare the array like so:

    Player players[1000] = { Player(100, 99), 
			     Player(23, 32), 
			     /* and so on ... */ };

If you truly want to do this on the fly, then you're out of luck, other
than declaring an array of pointers, and then dynamically allocating them.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
              "I am become death, / destroyer of worlds."
                                 / J. Robert Oppenheimer (quoting legend)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019