(no subject)

Date: 2004-01-21 11:19 pm (UTC)
From: (Anonymous)
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?

I'm using Visual 6.0.

Thanks
Jonathan

Profile

109: (Default)
109

March 2019

S M T W T F S
     12
3456789
101112131415 16
17181920212223
24252627282930
31      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags