为什么在 Ubuntu 上的 NetBeans 中找不到 std::p air

why cannot find std::pair in netbeans on ubuntu

本文关键字:std air 找不到 Ubuntu 上的 NetBeans 为什么      更新时间:2023-10-16

我刚刚在 ubuntu 上的 netbeans 中配置 c/c++当我尝试使用 std::p air 时,编译器似乎找不到它这很奇怪C++ 的默认版本是 C++11我的代码的一部分

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

提前致谢

您需要在

源文件的开头包含正确的头文件,以便编译器知道不同的类型/对象:

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

如果需要,默认情况下使用 std 命名空间(通常在 main() 之前):

using namespace std;