[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference pamsrc::objectbroker_development

Title:ObjectBroker Development - BEA Systems' CORBA
Notice:See note 2 for kit locations; note 4 for training
Moderator:RECV::GUMBELd
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.RTitleUserPersonal
Name
DateLines
2436.1This is a bug, PTR 16-4-2RECV::VLATASWARNING: Do not swallow the battery doorTue Feb 18 1997 06:4010
    
    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