What if the virtual function is actually a pure virtual function and we try to call it from the destructor? I have tried it and it won't link.
A::~A() { pure_virtual_func(); // Don't link }
But if you declare another function in class A and you call the pure virtual function in it, this will compile and link correctly.
void A::DoIt() { pure_virtual_func(); }
Finally, if I call A::DoIt() from the destructor of class A this will link.
A::~A() { DoIt(); // Link correctly }
But if you try to run this, you'll have a run-time exception error.
Is there a good explanation that if I call directly the pure virtual function from the destructor it won't link and if I call it indirectly from another function everything is fine?
(no subject)
Date: 2004-01-21 11:19 pm (UTC)A::~A()
{
pure_virtual_func(); // Don't link
}
But if you declare another function in class A and you call the pure virtual function in it, this will compile and link correctly.
void A::DoIt()
{
pure_virtual_func();
}
Finally, if I call A::DoIt() from the destructor of class A this will link.
A::~A()
{
DoIt(); // Link correctly
}
But if you try to run this, you'll have a run-time exception error.
Is there a good explanation that if I call directly the pure virtual function from the destructor it won't link and if I call it indirectly from another function everything is fine?
I'm using Visual 6.0.
Thanks
Jonathan