简单问题,快快快快快
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个错误
问题点数:50、回复次数:11Top
1 楼tony1978(突击召唤师)回复于 2003-01-09 13:19:33 得分 0
#include <iostream>
using namespace std;
Top
2 楼qing_li73(Vincent Lee)回复于 2003-01-09 13:19:46 得分 0
Do u overrided the operator in the current project ?Top
3 楼qing_li73(Vincent Lee)回复于 2003-01-09 13:21:05 得分 0
or sth about namespaceTop
4 楼tony1978(突击召唤师)回复于 2003-01-09 13:21:54 得分 50
1、包含标准头文件应该使用<>,不是错误,但是应该养成良好的习惯。
2、iostream.h是为了兼容c语言而保留的,这里面不包含对C++扩展的支持,比如不支持string类型Top
5 楼tony1978(突击召唤师)回复于 2003-01-09 13:23:17 得分 0
还有,在一个工程中,不要混用包含.h和不包含.h的C++标准库头文件。Top
6 楼demetry(智者橡木)回复于 2003-01-09 13:25:11 得分 0
1.error C2678:你可能在两个项目中,一个重载了!=,一个没有
2。error C2872:你可能直接引用的其他类的成员Top
7 楼jhnhu(玩的就是技术)回复于 2003-01-09 13:33:48 得分 0
#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)Top
8 楼jhnhu(玩的就是技术)回复于 2003-01-09 13:38:19 得分 0
cout << mysms->tel_num << endl << mysms->msg << endl;
这里的问题Top
9 楼loopyifly(深情咸鱼)回复于 2003-01-09 13:42:19 得分 0
用strcmp(strMyService , "MyService1") != 0
return false;
不可以吗?Top
10 楼jhnhu(玩的就是技术)回复于 2003-01-09 13:46:15 得分 0
用 strMyService.compare() 已经解决了
cout << mysms->tel_num << endl << mysms->msg << endl;
这个 -> 符号的问题Top
11 楼jhnhu(玩的就是技术)回复于 2003-01-09 13:59:59 得分 0
换成这个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 externalsTop




