#include<iostream.h> class CuriousTab { int x; public: CuriousTab(short ss) { cout<< "Short" << endl; } CuriousTab(int xx) { cout<< "Int" << endl; } CuriousTab(char ch) { cout<< "Char" << endl; } ~CuriousTab() { cout<< "Final"; } }; int main() { CuriousTab *ptr = new CuriousTab('B'); return 0; }
#include<iostream.h> class CuriousTab { int x, y; public: CuriousTab(int xx = 0, int yy = 0) { x = xx; y = yy; } void Display() { cout<< x << " " << y; } CuriousTab operator +(CuriousTab z) { CuriousTab objTemp; objTemp.x = x + z.x; objTemp.y = y + z.y; return objTemp; } }; int main() { CuriousTab objCuriousTab1(90, 80); CuriousTab objCuriousTab2(10, 20); CuriousTab objSum; CuriousTab &objRef = objSum; objRef = objCuriousTab1 + objCuriousTab2; objRef.Display(); return 0; }
#include<iostream.h> class CuriousTabBase { protected: int x, y; public: CuriousTabBase(int xx = 0, int yy = 0) { x = xx; y = yy; } void Show() { cout<< x * this->y << endl; } }; class CuriousTabDerived { private: CuriousTabBase objBase; public: CuriousTabDerived(int xx, int yy) : objBase(xx, yy) { objBase.Show(); } ~CuriousTabDerived() { } }; int main() { CuriousTabDerived objDev(10, 20); return 0; }
#include<iostream.h> class Number { int Num; public: Number(int x = 0) { Num = x; } void Display(void) { cout<< Num; } void Modify(); }; void Number::Modify() { int Dec; Dec = Num % 13; Num = Num / 13; if(Num > 0 ) Modify() ; if(Dec == 10) cout<< "A" ; else if(Dec == 11) cout<< "B" ; else if(Dec == 12) cout<< "C" ; else if(Dec == 13) cout<< "D" ; else cout<< Dec ; } int main() { Number objNum(130); objNum.Modify(); return 0; }
#include<iostream.h> class CuriousTab { int x, y; public: CuriousTab(int &xx, int &yy) { x = xx; y = yy; Display(); } void Display() { cout<< x << " " << y; } }; int main() { int x1 = 10; int &p = x1; int y1 = 20; int &q = y1; CuriousTab objCuriousTab(p, q); return 0; }
#include<iostream.h> class Base { public: char S, A, M; Base(char x, char y) { S = y - y; A = x + x; M = x * x; } Base(char, char y = 'A', char z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { char x, y, z; public: Derived(char xx = 65, char yy = 66, char zz = 65): Base(x) { x = xx; y = yy; z = zz; } void Display(int n) { if(n) Base::Display(); else cout<< x << " " << y << " " << z << endl; } }; int main() { Derived objDev; objDev.Display(0-1); return 0; }
#include<iostream.h> static double gDouble; static float gFloat; static double gChar; static double gSum = 0; class BaseOne { public: void Display(double x = 0.0, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class BaseTwo { public: void Display(int x = 1, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class Derived : public BaseOne, BaseTwo { void Show() { cout << gSum; } }; int main() { Derived objDev; objDev.BaseTwo::Display(10, 20, 'Z'); return 0; }
#include<iostream.h> class CuriousTab { int x; float y; public: CuriousTab(int x) { x = x; } CuriousTab(int p = 0, int q = 10) { x = p += 2; y = q * 1.0f; } void SetValue(int &y, float z) { x = y; y = (int)z; } void Display(void) { cout<< x; } }; int main() { int val = 12; CuriousTab objCuriousTab(val); CuriousTab objTmp(); objCuriousTab.SetValue(val, 3.14f); objCuriousTab.Display(); return 0; }
#include<iostream.h> class CuriousTabBase { int x, y; public: CuriousTabBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { cout<< x * y << endl; } }; class CuriousTabDerived : public CuriousTabBase { private: CuriousTabBase objBase; public: CuriousTabDerived(int xx, int yy) : CuriousTabBase(xx, yy), objBase(yy, yy) { objBase.Show(); } }; int main() { CuriousTabDerived objDev(10, 20); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.