How do I check whether the data members of two objects belonging to the same class are equal? Will the following code do or is it done in some other manner??
class Sample
{
int a;
public:
S(int x)
{
a = x;
}
int getA()
{
return a;
}
void putA()
{
cout<<a;
}
};
int main()
{
Sample s1(4), s2(4);
if(s1 == s2) //IS THIS ALRIGHT??
{
cout<<"Same";
}
return 0;
}