Base() {cout«"Base sinfi konstruktori \n";} ~Base() {cout«"Base sinfi destruktori \n";} }; class Derived: public Base { public: Derived() {cout«"Derived sinfi konstruktori \n";} ~Derived() {cout«"Derived sinfi destruktori \n ;} }; int main () { Derived d; return 0; } Natija: Base sinfi konstruktori Derived sinfi konstruktori Derived sinfi destruktori Base sinfi destruktori Quyida keltirilgan dasturda ikkita oddiy geometrik obyekt - doira va silindrning sinflar tabaqalanishi e'lon qilingan. Dastur shunday tuzilganki, bunda doiraning r — radiusi va silindrning h - balandligi o'zgaruvchilarining ichki qiymatlari yaratilayotgan obyektlar parametrlarini aniqlashi kerak. Circle bazaviy sinfi doirani modellashti- radi, Cylinder hosila sinfi esa silindrni modellashtiradi. #include < iostream.h> #include const double pi=4 * atan(l); class Circle { protected: double r; public: Circle (double rVal=0): r(rVal) {} void setRadius(double rVal) {r=rVal;}; double getRadius() {return r;}; double Area() {return pi*r*r;}; void showData(); }; class Cylinder: public Circle { protected: double h; public: Cylinder(double hVal=0, double rVal = 0)