கீழே கொடுக்கப்பட்டுள்ள நிரலின் வெளியீட்டை எழுதுக.
#include < iostream >
using namespace std;
class Test
{
private:
int X;
intY;
public:
Test (int , int ); //parameterized constructor
declaration
Test (Test &); //Declaration of copy constructor
to initialize data members.
void Display();
};//End of class
Test:: Test(int a, int b) //Definition of parameterized
constructor.
{
X=a;
Y=b;
}
Test: :Test(Test &T) //Definition of copy constructor.
{
X=T.X;
Y=T.Y;
}
void Test:: Display()//Definition of Display ()
member function.
{
cout << endl << "X:" << X;
cout << endl << "Y: " << Y << endl;
}
intmain()
{
Test T1(10,20) ; //Parameterized Constructor
automatically called when
//object is created.
cout << endl << "T1 Object: " << endl;
cout << "Value after initialization: " ;
T1.Display();
Test T2(T1 );//lntialize object with other object
using copy constructor
cout << endl << "T2 Object: " << endl;
cout << "Value after initialization: ";
T2.Display();
return 0;
}