#include<iostream.h> int main() { int x = 80; int y& = x; x++; cout << x << " " << --y; return 0; }
#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; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.