Hi Banfa ,
Can we overload destructor ? If yes then plz provide an example ?
If not then why ?
Can we overload destructor ? If yes then plz provide an example ?
If not then why ?
#include <stdio.h> #include <conio.h> class abc { public: abc() { printf("Constructor is called\n"); } ~abc() { printf("Destructor is called\n"); } }; class xyz:abc { public: xyz() { printf(" Derived Constructor is called\n"); } ~xyz() { printf(" Derived Destructor is called\n"); } }; void main() { clrscr(); abc *a = new abc(); xyz *x = new xyz(); //abc *b = new xyz(); delete a; delete x; //delete b; getch(); }
class Base { public: Base() {} ~Base() {} }; class Derived : public Base { public: Derived() {} ~Derived() {} };
Comment