#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; }
#include<iostream.h> #include<string.h> class CuriousTab { public: void GetData(char *s, int x, int y ) { int i = 0; for (i = x-1; y>0; i++) { cout<< s[i]; y--; } } }; int main() { CuriousTab objCuriousTab; objCuriousTab.GetData((char*)"Welcome!", 1, 3); return 0; }
#include<iostream.h> int i, j; class CuriousTab { public: CuriousTab(int x = 0, int y = 0) { i = x; j = x; Display(); } void Display() { cout<< j <<" "; } }; int main() { CuriousTab objCuriousTab(10, 20); int &s = i; int &z = j; i++; cout<< s-- << " " << ++z; return 0; }
#include<iostream.h> class Base { public: int S, A, M; Base(int x, int y) { S = y - y; A = x + x; M = x * x; } Base(int, int y = 'A', int z = 'B') { S = y; A = y + 1 - 1; M = z - 1; } void Display(void) { cout<< S << " " << A << " " << M << endl; } }; class Derived : public Base { int x, y, z; public: Derived(int xx = 65, int yy = 66, int zz = 67): 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(-1); return 0; }
#include<iostream.h> int CuriousTabFunction(int a, int b = 3, int c = 3) { cout<< ++a * ++b * --c ; return 0; } int main() { CuriousTabFunction(5, 0, 0); return 0; }
#include<iostream.h> class CuriousTab { int x; float y; public: void Function() { x = 4; y = 2.50; delete this; } void Display() { cout<< x << " " << y; } }; int main() { CuriousTab *pCuriousTab = new CuriousTab(); pCuriousTab->Function(); pCuriousTab->Function(); pCuriousTab->Display(); return 0; }
#include<iostream.h> #include<string.h> class CuriousTab { char str[50]; char tmp[50]; public: CuriousTab(char *s) { strcpy(str, s); } int CuriousTabFunction() { int i = 0, j = 0; while(*(str + i)) { if(*(str + i++) == ' ') *(tmp + j++) = *(str + i); } *(tmp + j) = 0; return strlen(tmp); } }; int main() { char txt[] = "Welcome to CuriousTab.com!"; CuriousTab objCuriousTab(txt); cout<< objCuriousTab.CuriousTabFunction(); return 0; }
#include<iostream.h> #include<string.h> class CuriousTab { char txtMsg[50]; public: CuriousTab(char *str = NULL) { if(str != NULL) strcpy(txtMsg, str); } int CuriousTabFunction(char ch); }; int CuriousTab::CuriousTabFunction(char ch) { static int i = 0; if(txtMsg[i++] == ch) return strlen((txtMsg + i)) - i; else return CuriousTabFunction(ch); } int main() { CuriousTab objCuriousTab("Welcome to CuriousTab.com!"); cout<< objCuriousTab.CuriousTabFunction('t'); return 0; }
Comments
There are no comments.Copyright ©CuriousTab. All rights reserved.