CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

简单问题,快快快快快

楼主jhnhu(玩的就是技术)2003-01-09 13:14:18 在 VC/MFC / 基础类 提问

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

相关问题

  • 简单问题大送分!!快快快!
  • 简单问题 快快看看!
  • 很简单,谁答的快谁得分!!!!!!!!!!!!!!!!!!快快快
  • 快!快快!!来拿分呀!!!!!!!!一个简单问题。
  • 快!快!快!
  • 快快快!
  • 简简单单提问,快快乐乐拿分
  • 一个简单的问题!请快快回信!在线等待!
  • 请问这一句那里错了,简单?在线等,快快!
  • 快快!!

关键词

  • c++
  • 文件
  • cconnectthread
  • tel
  • lnk
  • 问题
  • unresolved externals
  • std
  • error
  • msg

得分解答快速导航

  • 帖主:jhnhu
  • tony1978

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo