Re: Multiple inheritance and pointer equivalence
io_x schrieb:
"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4b0f84ec$0$10444$4fafbaef@reader2.news.tin.it...
"Danny Woods" <dannywoodz@yahoo.co.uk> ha scritto nel messaggio
news:50skccrsex.fsf@gmail.com...
Hi all,
Given this simple program:
----
#include <cstdio>
class A { public: virtual ~A() {} };
class B { public: virtual ~B() {} };
class C : public A, public B { public: virtual ~C() {} };
int main(void)
{
C *c = new C();
A *a = c;
B *b = c;
printf("c: %p; a: %p; b: %p\n", c, a, b);
delete c;
return 0;
}
----
i not find in the example above no double free;
where is it?
There's no double delete in this code. The double delete occured in
another usage/situation the OP described.
where is the problem?
the debugger show that the call for construction
are C()A()B()
and for distruction ~C()~B()~A()
(this mean that printf print someting wrong here below)
where is the problem?
A()B()C()
c: 00852FC0; a: 00852FC0; b: 00852FC8
~C(); this=00852FC0
~B(); this=00852FC8
~A(); this=00852FC0
END
Your debugger is wrong. The base classes are constructed first, followed
by the derived class.
--
Thomas