c++ Set无法正确编译

标签 c++ compiler-errors set ntl

我正在创建一个数据结构,但是当我尝试编译时,我收到一条错误消息,指出我没有指定我正在初始化的集合类型。

我正在使用用于大量数据的 NTL 库。

这是我的代码:

#include <set>
#include ...

NTL_CLIENT

using namespace std;
using namespace NTL;

const RR ZERO = to_RR(0);
const RR ONE = to_RR(1);
const RR TWO = to_RR(2);

class tenTree
{
   public:
      tenTree(string  newName = "", int newLevel = 0);
      ~tenTree();
      void put(string prefix, RR power);
      bool get(string prefix, RR & output);
      void display(int depth);
      bool isKnown(RR power){return (powers.find(power) != powers.end());};
   private:
      tenTree* children [10];
      set<int> powers;
      int level;
      string name;
      bool child[10];
};

当我尝试编译时返回错误信息:

twoPow.cpp:47: error: ISO C++ forbids declaration of \u2018set\u2019 with no type
twoPow.cpp:47: error: expected \u2018;\u2019 before \u2018<\u2019 token
twoPow.cpp: In member function \u2018bool tenTree::isKnown(NTL::RR)\u2019:
twoPow.cpp:44: error: \u2018powers\u2019 was not declared in this scope

我在这里遗漏了什么吗?

最佳答案

这只是范围的问题。我所要做的就是在 set 之前添加一个 std::并且它可以正确编译。

关于c++ Set无法正确编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17711936/

相关文章:

c++ - 初始化结构指针的值

c++ - 错误:在C++中没有用于调用构造函数的匹配函数

c++ - Qt:如何在任何 Windows 机器上使用路径创建文件?

c++ - 此错误会导致什么 C++ 模板问题?

compiler-errors - (...)*构造中的JAVACC ERROR选择冲突

facebook - 快速比较集

java - 如何使用 Guava 将 MultiMap<Integer, Foo> 转换为 Map<Integer, Set<Foo>>?

c++ - boost 函数和 lambda 来包装一个函数

java - 无法在 NetBeans 中找到 main

c - 在 C 中模拟列表