Re: Question on dynamic binding
On May 24, 5:53 pm, Salt_Peter <pj_h...@yahoo.com> wrote:
On May 24, 10:37 am, Soumen <soume...@gmail.com> wrote:
[...]
By the way, your Base dtor should be virtual (which would also imply
that derivative dtors will also be virtual).
delete pBase; // is a memory leak otherwise.
It's undefined behavior otherwise. In fact, I don't think I've
actually seen a case where it was a memory leak (although it's
certainly possible); I have seen core dumps because of it,
however. Most of the time, however, it works fine in all of
your tests, only to core dump dramatically when you do the demo
for your most important client. (Seriously: most of the time,
it works with single inheritance, but corrupts the free space
arena when multiple inheritance is involved, so you get some
strange error further down the road, in totally unrelated code.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34