deleting an object from its baseclass

Home Forums C Programming deleting an object from its baseclass

This topic contains 0 replies, has 1 voice, and was last updated by  si_icarus 9 years, 11 months ago.

  • Author
    Posts
  • #2144

    si_icarus
    Member

    I have a base class called ObjectBase which has a method killMe() which does some cleanup and then ‘delete this’. When I extend that class i’ve noticed I’m getting errors on the console

    malloc: *** error for object 0x48fe84: Non-aligned pointer being freed

    (I’m on osx and this error comes up when you try to delete memory not belonging to valid pointer).

    I’ve noticed I get this when my subclass has multiple base classes, and ObjectBase is not first in the list. I’ve also noticed the address it gives in the error is not the address of the pointer but slightly offset. So then it occurred to me that maybe the ‘delete this’ in ObjectBase isn’t freeing the whole object but only the ObjectBase part of the object… is this the case? If so is there any way I can delete the whole object from its base class?

You must be logged in to reply to this topic.