delorie.com/archives/browse.cgi | search |
Message-ID: | <36DDB4F4.F84E5CC8@xyz.net> |
From: | =?iso-8859-1?Q?Bj=F8rn?= Hansen <viking AT xyz DOT net> |
X-Mailer: | Mozilla 4.5 [en] (Win95; I) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: pointer question |
References: | <36DC0B86 DOT 843FC788 AT xyz DOT net> <36DC9B8C DOT F6D3D655 AT cartsys DOT com> |
Lines: | 55 |
NNTP-Posting-Host: | 207.14.89.140 |
X-Trace: | news7.ispnews.com 920531865 207.14.89.140 (Thu, 04 Mar 1999 02:17:45 EDT) |
NNTP-Posting-Date: | Thu, 04 Mar 1999 02:17:45 EDT |
Date: | Wed, 03 Mar 1999 22:17:25 +0000 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Ah, thank you it works just dandy now. Of course I have hit a nother snag. If I want to allocate memory for a nother Ship, scouts[1], how do i do it. it doesn't work to do: scouts[1]=new Ship ; but I now realise that is because it's not a pointer but how come this wont work: &scouts[1]=new Ship; or this scouts+1=new Ship; Do I have to allocate as much memory as I want at the same time like: scouts=new Ship[50]; ? I would like to not have a limit of how many Ship members scouts can have but I don't know how to do it. Nate Eldredge wrote: > Bjørn Hansen wrote: > > > > If I have a global pointer to a Ship class I made declared like this: > > > > Ship *scouts=NULL > > > > and then in my main function I do this: > > > > scouts=new Ship > > > > why can't I do this in one of my other functions? > > > > Ship *selected_ship; > > selected_ship=scouts[0]; > > `scouts[0]' is not a Ship *, but a plain Ship. You probably want: > > &(scouts[0]) > > or > > scouts + 0 > > or plain > > scouts > > HTH > -- > > Nate Eldredge > nate AT cartsys DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |