Re: interface programming

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom> wrote in message
news:uyKL%23W9VGHA.4196@xxxxxxxxxxxxxxxxxxxx
I am using *pure* virtual c++ class. I don't think I can put a
virtual dtor in a pure virtual class.

This is nonsense. You certainly can put a virtual dtor in a pure
virtual class.
And if you do not, the compiler with automagically generate a dtor
for you. But it is academic as the compiler's version and your
version are likely to be the same.
In situations like this, accept the compilers version.

It's not at all academic. Consider:

struct IMyInterface {...}; // no destructor
class MyClass : public IMyInterface {...};

IMyInterface* MyClassFactory() { return new MyClass;}

IMyInterface* p = MyClassFactory();
p->DoSomething();
delete p; // without virtual destructor, this does the wrong thing


This code exhibits undefined behavior under C++ standard 5.3.5/3
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.