Predict the output of following program?


			  		

Loading

Practice Constructors and Destructors –

Predict the output of following program?

#include
using namespace std;

class Point {
public:
Point() { cout << "Normal Constructor called "; }
Point(const Point &t) { cout << "Copy constructor called "; }
};

int main()
{
Point *t1, *t2;
t1 = new Point();
t2 = new Point(*t1);
Point t3 = *t1;
Point t4;
t4 = t3;
return 0;
}

Find the output of following program.


			  		

Loading

Practice Function Overloading –

Find the output of following program.

#include
using namespace std;

class Base
{
public:
virtual void show() { cout<<" In Base "; }
};

class Derived: public Base
{
public:
void show() { cout<<"In Derived "; }
};

int main(void)
{
Base *bp = new Derived;
bp->Base::show(); // Note the use of scope resolution here
return 0;
}

Predict the output of following program?


			  		

Loading

Practice Function Overloading –

Predict the output of following program?

#include
using namespace std;

class Base
{
public:
virtual void show() { cout<<" In Base "; }
};

class Derived: public Base
{
public:
void show() { cout<<"In Derived "; }
};

int main(void)
{
Base *bp, b;
Derived d;
bp = &d;
bp->show();
bp = &b;
bp->show();
return 0;
}

What is the output of following program?


			  		

Loading

Practice Function Overloading –

What is the output of following program?

#include
using namespace std;

class Base
{
public:
virtual void show() { cout<<" In Base "; }
};

class Derived: public Base
{
public:
void show() { cout<<"In Derived "; }
};

int main(void)
{
Base *bp = new Derived;
bp->show();

Base &br = *bp;
br.show();

return 0;
}