1.这是怎么回事,在另一个project里就无问题,难道又差了什么头文件?已经#include "iostream.h" 了
string strMyService ="0123456789";
for (i=0;i<10;i++)
    strMyService[i]=buf[i];  //获得 标识字符串
if (strMyService != "MyService1") return false;  //如果不正确 就退出
error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)error C2872:binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)error C2872: 'cout' : ambiguous symbol共3个错误

解决方案 »

  1.   

    #include <iostream>
    using namespace std;
      

  2.   

    Do u overrided the operator in the current project ?
      

  3.   

    1、包含标准头文件应该使用<>,不是错误,但是应该养成良好的习惯。
    2、iostream.h是为了兼容c语言而保留的,这里面不包含对C++扩展的支持,比如不支持string类型
      

  4.   

    还有,在一个工程中,不要混用包含.h和不包含.h的C++标准库头文件。
      

  5.   

    1.error C2678:你可能在两个项目中,一个重载了!=,一个没有
    2。error C2872:你可能直接引用的其他类的成员
      

  6.   

    #include <iostream>
    解决了 !=  cout 的问题还剩
    error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable c
    onversion)
      

  7.   

    cout << mysms->tel_num << endl << mysms->msg << endl;
    这里的问题
      

  8.   

    用strcmp(strMyService , "MyService1") != 0
       return false;
    不可以吗?
      

  9.   

    用 strMyService.compare() 已经解决了cout << mysms->tel_num << endl << mysms->msg << endl;
    这个 ->  符号的问题
      

  10.   

    换成这个printf("%s\n%s\n",mysms->tel_num,mysms->msg);又link error 了ConnectThread.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CConnectThread::GetMessageMap(void)const " (?GetMessageMap@CConnectThread@@MBEPBUAFX_MSGMAP@@XZ)
    ConnectThread.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CConnectThread::GetRuntimeClass(void)const " (?GetRuntimeClass@CConnectThread@@UBEPAUCRuntimeClass@@XZ)
    Debug/MServer.exe : fatal error LNK1120: 2 unresolved externals