C
ctick
In C++ FAQ 20.5, "...here are the mechanical details of why you need a
virtual destructor when someone says delete using a Base pointer that's
pointing at a Derived object. When you say delete p, and the class of p has
a virtual destructor, the destructor that gets invoked is the one associated
with the type of the object *p, not necessarily the one associated with the
type of the pointer. This is A Good Thing. In fact, violating that rule
makes your program undefined."
What's "the class of p", Base class?
What's "the type of the object *p", Base or Derived?
"the destructor that gets invoked is..."
Both destructors in Base AND Derived are invoked. Why only one is mentioned
here?
Thanks in advance!
virtual destructor when someone says delete using a Base pointer that's
pointing at a Derived object. When you say delete p, and the class of p has
a virtual destructor, the destructor that gets invoked is the one associated
with the type of the object *p, not necessarily the one associated with the
type of the pointer. This is A Good Thing. In fact, violating that rule
makes your program undefined."
What's "the class of p", Base class?
What's "the type of the object *p", Base or Derived?
"the destructor that gets invoked is..."
Both destructors in Base AND Derived are invoked. Why only one is mentioned
here?
Thanks in advance!