找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 295|回复: 7

请教string的问题

[复制链接]
发表于 2009-11-3 03:19:30 | 显示全部楼层 |阅读模式 IP:江苏扬州
include<iostream.h>
#include<string>
#include<stdlib.h>
#include<fstream.h>
class Sequence
{
public:
bool adds( int , const string& );
bool del(int);
void output() const;
Sequence():last(-1){}
Sequence(const char*);
~Sequence();
protected:
string s[50];
int last;
private:
string filename;
ifstream in;
ofstream out;
};
我用了很多方法,都不能编译通过为什么呢?string这个类型到底在c++中怎么用呢?#include<string.h>
#include<cstring.h>
#include<string>
这三个都不行,请指教!
发表于 2009-11-3 03:19:31 | 显示全部楼层 IP:江苏扬州
我看了一些书,有的有,有的没有 .象string这个头文件为什么就非要命名空间呢?
回复

使用道具 举报

发表于 2009-11-3 03:19:32 | 显示全部楼层 IP:江苏扬州
好象跟程序运行的环境有关.我也是用了这个头文件出现很多错误
回复

使用道具 举报

发表于 2009-11-3 03:19:33 | 显示全部楼层 IP:江苏扬州
#include<string>
using namespace std;
回复

使用道具 举报

发表于 2009-11-3 03:19:33 | 显示全部楼层 IP:江苏扬州
也可以using std::string;
回复

使用道具 举报

发表于 2009-11-3 03:19:35 | 显示全部楼层 IP:江苏扬州
<string>是98年最新的C++标准定义的
<string.h>是以前的

不一样。

也就是说如果#include <string.h>
就不用写using std::string或者using namespace std;
如果#include <string>
就必须要指明名字空间,因为98年最新的C++标准是这么定义的。
回复

使用道具 举报

发表于 2009-11-3 03:19:36 | 显示全部楼层 IP:江苏扬州
听这个名字和学校好象是老师呢
aogun斑竹有一个帖专门讲了这个
.h 与using 的区别 讲的很深
楼主有兴趣可以去查,收益非浅
回复

使用道具 举报

发表于 2009-11-3 03:19:37 | 显示全部楼层 IP:江苏扬州
throw out the IDE about VC, it was built in 1997 year, and that the ISO/C98 was built in 1998 year
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 13:18 , Processed in 0.213821 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表