Re: Virtual Function Problemo
Posted: Tue Sep 20, 2011 7:12 pm
Thank you very much for your replies I feel like such a noob though ahhaha :P. Well I guess I am but still :Pszdarkhack wrote:Damn, how did i miss that... Anyway, yes, anytime you use virtual functions it's a rule of thumb to make your base destructor virtual as well, otherwise you get some serious problems (depending on the occasion you can even slice your object in half and leak the base part). So make sure to always use virtual destructors when you want polymorphismGinto8 wrote:If your issue is with a base type destructor, you're probably trying to delete a BaseImage* that actually stores a SWRImage2D. Now I couldn't find that situation in any of the posted code, but if that's the issue, just declare ~BaseImage() as virtual ie:This causes the compiler to call the destructor of SWRImage2D even when it's being stored as a BaseImage.Code: Select all
virtual ~BaseImage() {}