You are on page 1of 1

// Copy constructor

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class sample
{
public:
int a,b;
sample(int x,int y)
{
a=x;
b=y;
}
void display()
{
cout<<"A="<<a<<endl;
cout<<"B="<<b<<endl;
}
sample(sample &s3)
{
a=s3.a;
b=s3.b;
}
};
int main()
{
sample s1(10,20);
sample s3=s1;
s1.display();
s3.display();
getch();
return 0;
}

You might also like