David Luff <[EMAIL PROTECTED]> writes :
> 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);
There are simple C++ patterns that can be applied to avoid this kind of
mess. For example, when you want that objects of the FGSimpleSound
class are always created on the heap, you can write :
class FGSimpleSound {
public :
static FGSimpleSound *create( /* parameters */ )
{ return new FGSimpleSound( /* parameters */ ); }
private : /* or protected */
FGSimpleSound( /* parameters */ ); // constructors
...
};
If constructors are private, no one except a friend or a member can create
an object. If they are protected, a derived class can create the object.
So the only way to create a FGSimpleSound is to call the static function 'create'
that always creates objects on the heap.
Just a bit of design.
Cheers,
-Fred
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel