On Friday 07 February 2003 00.09, Martijn Sipkema wrote: [...] > When dynamically linking C++ classes that imlement an interface you > can export create/destroy functions that return/take a pointer to a > instance. Note > that you should not use virtual destructors instead of a destroy > function since > the delete function called might not match the new from the > dynamically loaded code.
I had to think some before I realized what you're getting at. :-) Indeed, new and delete must be matched, since the ones in another binary might well use a different memory manager, or be wrapped or something. > > BTW, I believe this is about the way normal constructors work in > > Delpih/Object Pascal - which is why you cannot have static > > instances at all. No matter what you type, what you get is always > > a pointer. > > On of the best things about C++ is having auto storage classes, > since it makes resource management much easier/safer. I really > don't like Delphi/Object Pascal at all. Nor do I, really. The whole thing is a nice tool for RAD when it comes to some types of applications, but there are things like this particular language "feature" that are getting on my nerves at times. > I'm not sure but I believe > with Java it is also not possible to create classes on the stack, > but Java has a garabage collector (and that's not always convenient > for RT tasks). Or rather, it makes it useless for hard real time, unless 1) the underlying memory manager is deterministic (ie can run on a fixed, preallocated pool) and 2) you have full control over the garbage collector. //David Olofson - Programmer, Composer, Open Source Advocate .- The Return of Audiality! --------------------------------. | Free/Open Source Audio Engine for use in Games or Studio. | | RT and off-line synth. Scripting. Sample accurate timing. | `---------------------------> http://olofson.net/audiality -' --- http://olofson.net --- http://www.reologica.se ---