Feb 5, 2009 at 4:27am UTC
I'm a bit confused about destructors. I understand their functionality and why they are important... However, consider the following code in my base class:
1 2 3 4
virtual ~Employee()
virtual void ~calcPay()=0;
virtual void writeData();
virtual void readData();
Do I need a destructor in all of my derived classes?
Also, do I need to do anything special to these functions at implementation?
Last edited on Feb 5, 2009 at 4:51am UTC
Feb 5, 2009 at 7:36pm UTC
I think you do need a destructor for your derived class. As I remember, constructor and destructor are not inherited. Correct me if I am wrong.
Feb 6, 2009 at 1:48am UTC
They are "inherited" in that the derived class must be able to call the base's constructors and destructor.
Feb 6, 2009 at 1:58am UTC
They are inherited as jsmith said and don't need to be implemented because the compiler will provide one if one isn't defined.