OK, polymorphism bites me again. I have never quite got to grips with pointers and references in C/C++. Could anyone point me at a good explanatory text (no pun intended), or is it something that only clicks with extended use?
Richard > -----Original Message----- > From: David Luff [mailto:[EMAIL PROTECTED]] > Sent: 21 November 2002 10:13 am > To: [EMAIL PROTECTED] > Subject: RE: [Flightgear-devel] Got the sound working > > > On 11/21/02 at 8:24 AM Richard Bytheway wrote: > > >I might be missing a point, but it looks like the arguments to > >get_soundmgr are the other way round between the two versions. > > > > That's how they are in soundmgr.hxx (they're two different > functions - one > is passing in an FGSimpleSound pointer to the sound manager > and the other > the file name.) > > I've found the proper answer to my problem now - I was doing: > > FGSimpleSound simple("temp01.wav"); > globals->get_soundmgr()->add(&simple, refname); > > which doesn't work, whereas the following does work: > > FGSimpleSound* simple = new FGSimpleSound("temp01.wav"); > globals->get_soundmgr()->add(simple, refname); > > In my initial case, when simple went out of scope when my function > returned, this must have been leaving the sound manager with no > FGSimpleSound, and causing the fatal error. Thus no compile > time error, > but it wouldn't work. > > I guess I need to chant "A POINTER IS NOT THE SAME AS A REFERENCE" or > possibly "THE STACK IS NOT THE SAME AS THE HEAP" a couple of thousand > times! > > Given that I also got bitten by the > > char* str = "Hello"; > > is not the same as > > char str[] = "Hello"; > > business a few days ago, I feel like I've been slapped > repeatedly around > the head with a giant cod with C/C++ written on it!! > > Cheers - Dave _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel
