#include<iostream.h> int main() { int x = 10, y = 20; int *ptr = &x; int &ref = y; *ptr++; ref++; cout<< x << " " << y; return 0; }
#include<iostream.h> class CuriousTabBase { public: int x, y; public: CuriousTabBase(int xx = 0, int yy = 0) { x = xx; y = yy; } }; class CuriousTabDerived : public CuriousTabBase { private: CuriousTabBase objBase; public: CuriousTabDerived(int xx, int yy) : CuriousTabBase(xx), objBase(yy) { cout << x << " " << this->x << " " << CuriousTabBase::x << " " << this->objBase.x ; } ~CuriousTabDerived() { } }; int main() { CuriousTabDerived objDev(11, 22); return 0; }
#include<iostream.h> class CuriousTab { int x, y, z; public: CuriousTab(int x = 100, int y = 30, int z = 0) { this->x = x; this->y = y; this->z = z; Display(); } void Display() { cout<< x << " " << y << " " << z; } }; int main() { int a = 0, b = 1, c = 2; int &x = ++a; int &y = --b; int z = c + b - -c; CuriousTab objCuriousTab(x, y, z); return 0; }
#include<iostream.h> #include<string.h> #include<malloc.h> class CuriousTabString { char txtName[20]; public: CuriousTabString(char *txtTemp = NULL) { if(txtTemp != NULL) strcpy(txtName, txtTemp); } void Display(void) { cout<<txtName; } }; int main() { char *txtName = (char*)malloc(10); strcpy(txtName, "CuriousTab"); *txtName = 48; CuriousTabString objTemp(txtName); cout<< sizeof(txtName); return 0; }
#include<iostream.h> class Addition { int x; public: Addition() { x = 0; } Addition(int xx) { x = xx; } Addition operator + (int xx = 0) { Addition objTemp; objTemp.x = x + xx; return(objTemp); } void Display(void) { cout<< x << endl; } }; int main() { Addition objA(15), objB; objB = objA + 5; objB.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 { private: CuriousTabBase objBase; public: CuriousTabDerived(int xx, int yy) : objBase(xx, yy) { objBase.Show(); } }; int main() { CuriousTabDerived objDev(10, 20); return 0; }
#include<iostream.h> class Point { int x, y; public: Point(int xx = 10, int yy = 20) { x = xx; y = yy; } Point operator + (Point objPoint) { Point objTmp; objTmp.x = objPoint.x + this->x; objTmp.y = objPoint.y + this->y; return objTmp; } void Display(void) { cout<< x << " " << y; } }; int main() { Point objP1; Point objP2(1, 2); Point objP3 = objP1 + objP2; objP3.Display(); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.