Program to implement concept of copy constructor.

#include
#include
class manmeet
{
private:
int x;
float y;
public:
void getdata();
void display();
manmeet swap (manmeet);

};
void manmeet::getdata()
{
cout<>x;
cout<>y;
}
void manmeet::display()
{
cout<<"n Entered value of x was:"<<x;
cout<<"n Entered value of y was:"<<y;
}
manmeet manmeet::swap(manmeet p)
{
manmeet t;
t.x=p.x;
t.y=p.y;
return(t);
}
main()
{
clrscr();
manmeet a,b;
a.getdata();
b.getdata();
a.display();
cout<<"n";
b.display();
cout<<"nn";
getch();

a.swap(b);
b.swap(b);

a.display();
b.display();
getch();
return(1);
}

Leave a reply