[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | ObjectBroker Development - BEA Systems' CORBA |
Notice: | See note 2 for kit locations; note 4 for training |
Moderator: | RECV::GUMBEL d |
|
Created: | Thu Dec 27 1990 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 2482 |
Total number of notes: | 13057 |
2436.0. "Why are destructors not virtual" by UTROP1::OLERUD_G () Mon Feb 17 1997 05:58
Is there a way to get the destructors of implementations, in the
generated imh file, to be declared as virtual.
E.g. if you have an interface "MyInterface", the destructor is declared
as:
OBB_CXXAPI ~MyInterfaceImpl();
I would much rather prefer the destructor declared as:
virtual OBB_CXXAPI ~MyInterfaceImpl();
The reason for this is that if I declare a new class "MyClass" derived
from "MyInterfaceImpl" and I use a pointer to the base class, deletion
of this base class pointer invokes only the destructor of the base
class and not the derived classes.
Example:
class MyClass : public MyInterfaceImpl
{
.
.
virtual ~MyClass();
}
main ()
{
MyInterfaceImpl *pImpl = new MyClass;
.
.
delete pImpl;
}
This is the situation where the destructor of MyClass is never called.
In my opinion, the destructor should always be declared as virtual due
to this problem.
In addition, the destructor of OBB::OBB__server, in ORB.hxx, is also
not declared as virtual. Is there a reason for this?
Gunnar
T.R | Title | User | Personal Name | Date | Lines |
---|
2436.1 | This is a bug, PTR 16-4-2 | RECV::VLATAS | WARNING: Do not swallow the battery door | Tue Feb 18 1997 06:40 | 10 |
|
Funny you should mention this one...
This was brought to our attention yesterday morning and I entered a PTR
case on it. It is definately a bug that the destructor isn't declared
as "virtual" in the generated IMH.
The PTR number is 16-4-2.
Tony
|