日新微博
7
公司 :杭州神话信息技术有限公司
部门 :运营中心设计部
岗位 :UI视觉设计
9
关注
16
粉丝
18724
微博
21
被赞
新浪微博
原创达人
[个人/站长]
点击申请认证
友情链接:
找感兴趣的人
精彩内容
热门应用
关于我们
手机玩微博
include<iostream>
include<string>
using namespace std;
class Word{
public:
Word(strings):str(s){ }
string getStr( ){return str;}
______const{return(str<w.str);}
friend ostream& operator<<(ostream& output,const Word &w){output<<w.str;return output;}
private:
string str;
};
int main( ){
Word wl("Happy"),w2("Welcome");
cout<<"After sorting:";
if(wl<w2)cout<<w1<<"<<w2;
else cout<<w2<<''<<w1:
return 0;
}
正确答案:bool operator(Word w)bool operator(Word w) 解析:重载关系运算符“”为成员函数,得到逻辑类型结果,且只要一个参数。