一个奇怪的编译错误,头文件包含问题?

ChampionLai 2013-01-24 10:24:03
#include<stdio.h>
#include<queue>
using namespace std;[/i]如果是把这个更改为#include<queue.h> 用DEV C++就会出现编译错误[i]

int main()
{
queue<int> Q;
int n,temp;
scanf("%d",&n);
while(n--)
{
scanf("%d",&temp);
Q.push(temp);
}
while(!Q.empty())
{
char c = Q.front();
Q.pop();
printf("%c",c);
}
//getchar();
// getchar();
return 0;
}
编译提示信息是这样的
2 C:\Dev-Cpp\include\c++\3.3.1\backward\queue.h:31, from C:\Users\laicb\Desktop\机试\CPP\ASCII.cpp In file included from C:/Dev-Cpp/include/c++/3.3.1/backward/queue.h:31, from C:/Users/laicb/Desktop/机试/CPP/ASCII.cpp

2 C:\Dev-Cpp\include\c++\3.3.1\backward\backward_warning.h:32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
...全文
167 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
leez0301 2013-01-24
  • 打赏
  • 举报
回复
#include<queue> using namespace std; 这个是新标准, 为了兼容就的标准,依然支持#include<queue.h>这种写法,如果这种引用方法,你就按照旧的函数调用方法调用,试着不要用命名空间这东西了。 再者,你的这个文件queue.h确实存在么?,我的是没有这个。
startservice 2013-01-24
  • 打赏
  • 举报
回复
标准库中的头文件 C++标准库中的一切内容都被放在名字空间std中(名字空间中的内容对外是不可见的),但是带来了一个新问题,无数现有的C++代码都依赖于使用了多年的伪标准库中的功能,如声明在<iostream.h>等头文件中的功能,使用std包装标准库导致现有代码的不可用,为了兼容这种情况,标准委员会为包装了std的那部分标准库创建了新的头文件,新的头文件的文件名与旧的一样,只是没有.h这个后缀,如<iostream.h>就变成了<iostream>。对于C头文件,采用同样的方法,但还在每个头文件名前加了字符c,如<string.h>就变成了<cstring>,<stdio.h>变成了<cstdio>。最好使用新的文件头,使用新的文件头的C++程序,需要使用using namespace std或者using namespace std::指定的类名,等方法来使需要的类对于我们的代码可视。
ppsharp 2013-01-24
  • 打赏
  • 举报
回复
没用过这个编译器
lee_鹿游原 2013-01-24
  • 打赏
  • 举报
回复
都没有 这个queue.h,肯定错
ForestDB 2013-01-24
  • 打赏
  • 举报
回复
现代C++推荐<queue>加上using namespace std; <queue.h>只是为了向后兼容

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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