#include<iostream.h> class Base { int x, y; public: Base() { x = y = 0; } Base(int xx) { x = xx; } Base(int p, int q = 10) { x = p + q; y = q; } void Display(void) { cout<< x << " " << y << endl; } }objDefault(1, 1); class Derived: public Base { Base obj; public: Derived(int xx, int yy): Base(xx, xx + 1) { } Derived(Base objB = objDefault) { } }; int main() { Derived objD(5, 3); Derived *ptrD = new Derived(objD); ptrD->Display(); delete ptrD; return 0; }
#include<iostream.h> class CuriousTab { int x, y; public: CuriousTab(int xx = 10, int yy = 20 ) { x = xx; y = yy; } void Display() { cout<< x << " " << y << endl; } ~CuriousTab() { } }; int main() { CuriousTab objCuriousTab; objCuriousTab.Display(); return 0; }
#include<iostream.h> class CuriousTabBase { public: float x; }; class CuriousTabDerived : public CuriousTabBase { public: char ch; void Process() { ch = (int)((x=12.0)/3.0); } void Display() { cout<< (int)ch; } }; int main() { class CuriousTabDerived *objDev = new CuriousTabDerived; objDev->Process(); objDev->Display(); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.