Re: Compiling without warnings issues

Hi Petr,

I will be honest, I have never understood why the destructor should be protected and non-virtual. Even I had read the articel again.

http://www.gotw.ca/publications/mill18.htm

But maybe you can it explain more in detail.

That you should never derived from a class with a non-virtual destructor comes from Scott Meyers new book “Effective C++” http://www.amazon.com/o/ASIN/0321334876/ref=s9_asin_image_1/102-7425015-1366538?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-4&pf_rd_r=0SVN09DCNHRQ808H0Z88&pf_rd_t=101&pf_rd_p=278841901&pf_rd_i=507846

But I have the new version on work and not here.

I have now checked the documentation about QSharedData. It seems that it is designed for a base class. But this makes no sence for me. How should the compiler knows to call the right destrutor if there is no virtual talble?

QSharedData* pData = new DerivedQSharedData;
delete pData; // ???

Regards,
Markus

Would you like to post a relpy?


This post is a reply to:
Re: Compiling without warnings issues
Hi Markus, In Java you have a keyword which is called final, in C# it is sealed. If the classes are declared with this words you can not inherit from them. (more...)

Follow-ups:
Re: Compiling without warnings issues
Hi Markus, I will be honest, I have never understood why the destructor should be protected and non-virtual. Even I had read the articel again. [snip] But maybe you can it (more...)