After digging into the assembly code emitted by GCC 4.8
GCC will create two pieces of code (for a class whose destructor is virtual):
One is assembly snippet
And for a class whose destructor is not virtual, a call release function command will be generated at the place where you call delete.
(After discussion, suppose the destructor is virtual) So, for the following code:
delete C // This will be translate as call snippet
And if you use the following code:
p->C::~C()
Thus, the deallocate function is associated with a virtual destructor. Therefore, I think this will answer your question about how the deallocate function is implemented as virtual, but also static.
ZijingWu Jun 17 '13 at 7:06 on 2013-06-17 07:06
source share