简体   繁体   English

为什么在ubuntu上找不到netbeans中的std :: pair

[英]why cannot find std::pair in netbeans on ubuntu

I have just configured c/c++ in netbeans on ubuntu and when i try to use std::pair it seems that the compiler cannot find it that is very strange the default version of c++ is c++11 that a slice of my code 我刚刚在ubuntu上的netbeans中配置了c / c ++,当我尝试使用std :: pair时,似乎编译器找不到它很奇怪c ++的默认版本是c ++ 11那是我的一段代码

int n, k;
cin >> n>>k;
vector<pair<int,int> > x(n);

thanks in advance 提前致谢

You need to include the right header files a the beginning of your source files so that the compiler know the different types/objects: 您需要在源文件的开头包含正确的头文件,以便编译器知道不同的类型/对象:

#include <iostream> // For std::cin
#include <vector>   // For std::vector
#include <utility>  // For std::pair

And use the std namespace by default if you want (before main() typically): 如果需要,默认情况下使用std命名空间(通常在main()之前):

using namespace std;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM