Destructor Questions..

Feb 5, 2009 at 4:27am
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
Feb 5, 2009 at 1:38pm
No and no.
Feb 5, 2009 at 7:36pm
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
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
They are inherited as jsmith said and don't need to be implemented because the compiler will provide one if one isn't defined.
Topic archived. No new replies allowed.