首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

哪位给小弟我讲讲运算附重载,并给个简单的例子,20分全给你了。

2012-02-07 
哪位给我讲讲运算附重载,并给个简单的例子,20分全给你了。。。。RT[解决办法]private:int xfloat ystring st

哪位给我讲讲运算附重载,并给个简单的例子,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;
}

};

热点排行