编译错“'std' : is not a class or namespace name”我晕倒!!!

kobee 2004-04-06 10:11:18
哪位达人告知缘何如此?
...全文
2055 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pacman2000 2004-04-07
  • 打赏
  • 举报
回复
如果用了#include<fstream.h>
那么所有的东西都不会放在std名字空间里。
古布 2004-04-07
  • 打赏
  • 举报
回复
.h文件是为了和c兼容。
storm_yu 2004-04-07
  • 打赏
  • 举报
回复
标准库出台后为了不和以前的混淆
将类似于<fstream.h>的头文件
放入到叫stl 的namespace里
并叫头文件为<fstream>
stick1 2004-04-07
  • 打赏
  • 举报
回复
楼上说的没错,
.h和using namespace std;不要混用
zhouqingyuan 2004-04-07
  • 打赏
  • 举报
回复
如果没有不带.h的头文件,就不识别std
#include <iostream.h>
#include <vector>
using namespace std;
这样是可以的
nirvana_li 2004-04-07
  • 打赏
  • 举报
回复
'std' : is not a class or namespace name
这个Warning的意思是“std”这个名字不是类或者命名空间的名字。你的代码:
ofstream outFile;
outFile.open((LPCTSTR)fileName[i], std::ios_base::app);
使用了std这个命名空间。但是有
#include <fstream.h>
一个解决办法就是使用:
#include <fstream>
using namespace std;
....
ofstream outFile;
outFile.open((LPCTSTR)fileName[i], ios_base::app);//这里取消std::这个范围限制符
或者
#include <fstream>
//不包括using namespace std;
...
ofstream outFile;
outFile.open((LPCTSTR)fileName[i], std::ios_base::app);//在代码中使用std::范围限制
// 符
Dong 2004-04-06
  • 打赏
  • 举报
回复
<fstream.h>是标准库出台前的头文件。
<fstream>是标准库的头文件。
using namespace std;声明调用的是标准库的东西。
weixiaohua 2004-04-06
  • 打赏
  • 举报
回复
应该是<fstream>吧!
kobee 2004-04-06
  • 打赏
  • 举报
回复
头文件我#include<fstream.h>
没有using namespace std;(否则出现一堆莫名其妙的错误)
kobee 2004-04-06
  • 打赏
  • 举报
回复
相关代码:

ofstream outFile;
outFile.open((LPCTSTR)fileName[i], std::ios_base::app);

编译就出现题述错误!

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧