C++ Programming :: Objects and Classes
-
What will be the output of the following program?
#include class GateBase { public: float x; }; class GateDerived : public GateBase { public: char ch; void Process() { ch = (int)((x=12.0)/3.0); } void Display() { coutint)ch; } }; int main() { class GateDerived *objDev = new GateDerived; objDev->Process(); objDev->Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include#include class Freshergate { static int x; public: Freshergate() { if(x == 1) exit(0); else x++; } void Display() { cout" "; } }; int Freshergate::x = 0; int main() { Freshergate objgate1; objgate1.Display(); Freshergate objgate2; objgate2.Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include class GateBase { int x, y; public: GateBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { coutclass GateDerived { private: GateBase objBase; public: GateDerived(int xx, int yy) : objBase(xx, yy) { objBase.Show(); } }; int main() { GateDerived objDev(10, 20); r return 0; } -
Which of the following statement is correct about the program given below?
#include class BixBase { int x, y; public: GateBase(int xx = 10, int yy = 10) { x = xx; y = yy; } void Show() { coutclass GateDerived : { private: GateBase objBase; public: GateDerived(int xx, int yy) : GateBase(xx, yy) { objBase.Show(); } }; int main() { GateDerived objDev(10, 20); return 0; } -
What will be the output of the following program?
#include class A { public: void GateFunction(void) { cout"Class A" class B: public A { public: void GateFunction(void) { cout"Class B" class C : public B { public: void GateFunction(void) { cout"Class C" int main() { A *ptr; B objB; ptr = &objB; ptr = new C(); ptr->GateFunction(); return 0; } -
Which of the following statement is correct about the program given below?
#include class GateBase { int x, y; public: GateBase(int xx = 10, int yy = 10) { xx= xx; y = yy; } void Show() { coutclass GateDerived : public GateBase { private: GateBase objBase; public: GateDerived(int xx, int yy) : GateBase(xx, yy), objBase(yy, yy) { objBase.Show(); } }; int main() { GateDerived objDev(10, 20); return 0; } -
What will be the output of the following program?
#include 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" " } }:int main() }Point objP1; Point objP2(1, 2); Point objP3 = objP1 + objP2; objP3.Display(); return 0; } -
What will be the output of the following program?
#include #include class FresherGate { char str[50]; char tmp[50]; public: FresherGate(char *s) { strcpy(str, s); } int GateFunction() { 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 FresherGate.com!"; FresherGate objGate(txt); coutreturn 0; }

Whatsapp
Facebook