Re: interface programming
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Tue, 4 Apr 2006 07:53:35 -0400
"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
.
- Follow-Ups:
- Re: interface programming
- From: Stephen Howe
- Re: interface programming
- References:
- Re: interface programming
- From: Carl Daniel [VC++ MVP]
- Re: interface programming
- From: Stephen Howe
- Re: interface programming
- Prev by Date: Re: interface programming
- Next by Date: Re: interface programming
- Previous by thread: Re: interface programming
- Next by thread: Re: interface programming
- Index(es):