delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/02/21:16:31

Sender: nate AT cartsys DOT com
Message-ID: <36DC9B8C.F6D3D655@cartsys.com>
Date: Tue, 02 Mar 1999 18:16:44 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: pointer question
References: <36DC0B86 DOT 843FC788 AT xyz DOT net>
Reply-To: djgpp AT delorie DOT com

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

- Raw text -


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