哪位给我讲讲运算附重载,并给个简单的例子,20分全给你了。。。。
RT
[解决办法]
private:
int x;
float y;
string str;
public:
test(int a, float b, string s):x(a), y(b), str(s){}
bool operator ==(const test& a) const
{
if ( (a.x == x) && (a.y == y) && (a.str == str) )
{
return true;
}
else
return false;
}
bool operator != (const test& a) const
{
if ((a.x != x) || ( a.y != y ) || (a.str != str))
{
return true;
}
else
{
return false;
}
}
friend ostream& operator < <(ostream& s, const test& a)
{
s < < "test: " < < a.x < < " " < < a.y < < " " < < a.str < < endl;
return s;
}
};