#include <iostream>
using namespace std;
class Parent {
public:
Parent() {
cout << "constructor of parent\n";
}
// destructor of Parent class
~Parent() {
cout << "destructor of parent\n";
}
};
class Child : public Parent {
public:
Child() {
cout << "constructor of child\n";
}
//Destructor of Child
~Child() {
cout << "destructor of child\n";
}
};
int main() {
Child ch1;
return 0;
}
OUTPUT:
constructor of parent
constructor of child
destructor of child
destructor of parent
No comments:
Post a Comment