C++ Programming :: Constructors and Destructors
-
What will be the output of the following program?
#include class GateBase { public: GateBase() { cout"Base OK. "; } ~GateBase() { cout"Base DEL. "; } }; class GateDerived: public BixBase { public: GateDerived() { cout"Derived OK. "; } ~GateDerived() { cout"Derived DEL. "; } }; int main() { GateBase *basePtr = new GateDerived(); delete basePtr; return 0; } -
What will be the output of the following program?
#include class GateBase { public: GateBase() { cout"Base OK. "; } virtual ~GateBase() { cout"Base DEL. "; } }; class GateDerived: public BixBase { public: GateDerived() { cout"Derived OK. "; } ~GateDerived() { cout"Derived DEL. "; } }; int main() { GatetBase *basePtr = new GateDerived(); delete basePtr; return 0; } -
What will be the output of the following program?
#include class GateBase { public: int x, y; GateBase(int xx = 0, int yy = 5) { x = ++xx; y = --yy; } void Display() { cout class GateDerived : public GateBase { public: void Increment() { y++; } void Display() { cout }: } int main() { GateDerived objGate; objGate.Increment(); objGate.Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include class FresherGate { int x; public: FresherGate() { x = 0; } FresherGate(int xx) { x = xx; } FresherGate(FresherGate &objB) { x = objB.x; } void Display() { cout" "; } }; int main() { FresherGate objA(25); FresherGate objB(objA); FresherGate objC = objA; objA.Display(); objB.Display(); objC.Display(); return 0; } -
Which of the following statement is correct about the program given below?
#include class FresherGate { int x, y; public: FresherGate() { x = 0; y = 0; } FresherGate(int xx, int yy) { x = xx; y = yy; } FresherGate(FresherGate *objB) { x = objB->x; y = objB->y; } void Display() { cout" " int main() { FresherGate objGate( new FresherGate(20, 40) ); objGate.Display(); return 0; } -
What will be the out of the following program?
#include class GateBase { public: int x, y; public: GateBase(int xx = 0, int yy = 0) { x = xx; y = yy; } }; class GateDerived : public GateBase { private: GateBase objBase; public: GateDerived(int xx, int yy) : GateBase(xx), objBase(yy) { cout this->x " " this->y " " " " " "; } ~GateDerived() { } }; int main() { GateDerived objDev(11, 22); return 0; } -
What will be the out of the following program?
#include class GateBase { public: int x, y; public: GateBase(int xx = 0, int yy = 0) { x = xx; y = yy; } }; class GateDerived : public GateBase { private: GateBase objBase; public: GateDerived(int xx, int yy) : GateBase(xx), objBase(yy) { cout " " this->x " " " " this->objBase.x ; } ~GateDerived() { } }; int main() { GateDerived objDev(11, 22); return 0; }

Whatsapp
Facebook