C++ - std::set not declared

C++ - std::set not declared

本文关键字:not declared set C++ std      更新时间:2023-10-16
#include <iostream>
 using std::set;
 using std::cout;
 using std::endl;

错误报告:

Josephus_Permutation.cpp:3:13: error: ‘std::set’ has not been declared

std::set不应该是命名空间std的STL吗?

它位于std名称空间中,但您需要包含适当的标题:

#include <set>

<iostream>头文件只包含标准输入/输出库,其中包括std::coutstd::endl。而std::set<set>中定义。