Assignment operator

#include<iostream>
using namespace std;
class hi{
int i,j;
public:
hi() {}
hi(int a,int b) { i=a;
j=b;
}
void show()
{
cout<<endl<<i<<endl<<j<<endl;
}
hi operator = (hi ob1){
i=ob1.i;
j=ob1.j;
return *this;
}
};
int main()
{
hi ob1(2,3),ob2;
ob2=ob1;
ob2.show();
return 0;
}

Advertisements