[fpc-pascal]Polymorphism of class field
Kuba Ober
kuba at mareimbrium.org
Tue Oct 2 09:39:21 CEST 2001
> I probably should have looked up the definition of TObject in the docs
> before I started, but now that I have done so, I'm still confused. To
> destroy an instance of a class, I should call its destructor (which I've
> changed to Destoy, as you said I should). Thus the following should work
> *and is the proper way of doing this*:
The destructor does only what you write in it. If your class is allocated on
the heap, you must actually free the heap. That's what free() is for. free()
calls the destructor and then frees the heap, more or less like that
free(objptr);
equals
if objptr != nil then begin
objptr.Destroy;
freemem(objptr);
objptr = nuil; { NO, I DON'T KNOW IF THIS LINE IS ACTUALLY DONE! }
end;
I hope I didn't mess up things ;-)
Cheerz,
Kuba
More information about the fpc-pascal
mailing list