C++编译错误:“pair”未命名类型
C++ compilation error: ‘pair’ does not name a type
我正试图用g++编译器编译非常简单的c++程序。
//main.cpp
#include <stdio.h>
using namespace std;
typedef pair<int,int> pii;
int main(int argc, char *argv[])
{
printf("Hi");
return 0;
}
但我得到了编译错误:"pair"没有命名一个类型
编译行:g++main.cpp-o main.out操作系统:Ubuntu 16.04 ltsg++:gcc版本5.4.0 20160609(Ubuntu 5.4.0-6ubuntu1~16.04.2(
如果我只是添加#include<iostrem>
程序编译并成功运行:(
#include <stdio.h>
#include<iostream>
using namespace std;
typedef pair<int,int> pii;
int main(int argc, char *argv[])
{
printf("Hi");
return 0;
}
你知道为什么会这样吗?
我的错,答案很简单:(
1( 对于使用pair
,我应该包括<utility>
。
2( <iostream>
某处包含<utility>
,这就是为什么添加它后程序成功编译的原因:(
相关文章:
- C++包含函数标头会给出错误'__dest'未命名类型
- 错误:"cast"未命名类型void setCastDescription(std::string
- C++ 错误:(类名)未命名类型
- src/caffe/parallel.cpp:70:1:错误:“参数”未命名类型
- 错误:'int_type'未命名类型 - 如何继承 typedefs 和用法
- 如何修复错误,迭代器未在此范围内声明,并且迭代器未命名类型'
- 使用 mex 编译库时出错 - __int 64 未命名类型
- 错误:"某个类"未命名类型。如何解决这个问题?
- 命名空间中的'bad_cast' 'std' 未命名类型错误
- QT:错误 ["*"令牌之前的预期")",并且主窗口未命名类型]
- "root"未命名类型错误
- Stack.h:13:3:错误:“单元格”未命名类型
- 错误:命名空间“PQXX”中的“行”未命名类型
- YYY 中的错误 XXX 未命名类型
- C 构建错误:类未命名类型
- 错误:"QGeo坐标"未命名类型
- 错误:"__NDK_FPABI__"未命名类型
- 错误 - 列表节点未命名类型
- android-ndk-r6-crystax-2 错误:命名空间'std'中的'string'未命名类型
- 错误:未命名类型(使用 auto)