标题:求指点错误
只看楼主
cactusj
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-12-13
结帖率:0
已结贴  问题点数:10 回复次数:2 
求指点错误
#include<iostream>
#include<string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
    string s1="Zhaojunn",s2="Zhaojun";
   cin>>s1>>endl;
   cin>>s2>>endl;
   if(s1==s2)
       cout<<"s1=s2!!"<<endl;
   else
       if(s1>s2)
           cout<<"s1>s2!!"<<endl;
       else
           cout<<"s1<s2!!!"<<endl;

   return 0;
}


错误是:d:\vc++\day1\ex3_7\ex3_7.cpp(10) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
求高手指点~~~不胜感激!!
搜索更多相关主题的帖子: include return 
2012-12-13 15:05
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:5 
#include<iostream>
#include<string>
using namespace std;
int main()
{
   string s1,s2;
   cin>>s1;
   cin>>s2;
   if(s1==s2)
       cout<<"s1=s2!!"<<endl;
   else
       if(s1>s2)
           cout<<"s1>s2!!"<<endl;
       else
           cout<<"s1<s2!!!"<<endl;

   return 0;
}

DO IT YOURSELF !
2012-12-13 15:11
crystall
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:7
帖 子:184
专家分:809
注 册:2012-12-1
得分:5 
程序代码:
#include "stdafx.h"

#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s1 = "Zhaojun", s2="Zhaojun";

    cout << "请输入字符串1: ";
    cin >> s1;

    cout << "请输入字符串2: ";
    cin >> s2;

   if(s1==s2)
   {
       cout<< "s1 == s2" <<endl;
   }
   else
   {
       if(s1>s2)
           cout << "s1 > s2" << endl;
       else
           cout << "s1 < s2" << endl;
   }

   return 0;
}
2012-12-13 15:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-391080-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.733099 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved