Re: interface programming
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Tue, 4 Apr 2006 07:49:17 -0400
"Simon Trew" <noneofyour@xxxxxxxxxxxx> wrote in message
news:%23suYBt8VGHA.4772@xxxxxxxxxxxxxxxxxxxx
"dummy#1" <dummy1@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0736F76C-D13F-4B88-892D-BE8F4A1CF983@xxxxxxxxxxxxxxxx
I am using *pure* virtual c++ class. I don't think I can put a
virtual dtor
in a pure virtual class. There is nothing in the class to
deallocate.
Yes you can-- in fact, it's almost always the right thing to do to
make the destructor virtual, and making it pure is no great shakes,
since the compiler will supply a default destructor if one is not
defined in the derived class.
Not if you declare pure virtual destructor. Perhaps surprisingly, one
can provide an implementation for pure virtual functions, and in case of
a destructor one must in fact do so. Like this:
class IMyClass {
public:
virtual ~IMyClass() = 0;
};
IMyClass::~IMyClass() {}
Note also that COM interfaces don't typically have destructors, virtual
or otherwise (beyond a trivial one provided by the compiler, of course).
A COM object is expected to delete itself from inside Release() call,
which means that 'delete' is always issued from the context of the most
derived class, so virtual destructor is unnecessary.
--
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
.
- References:
- Re: interface programming
- From: Carl Daniel [VC++ MVP]
- Re: interface programming
- From: Simon Trew
- 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):
Relevant Pages
|