3
我正在創建一個數據結構,但是當我嘗試編譯時出現錯誤,說我沒有指定我正在初始化的那種類型的集合。C++設置不正確編譯
我正在與大量使用的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
有沒有,我很想念這裏的東西嗎?
我認爲這是一個頭文件。 Plase **永遠不會**在標題文件中使用'namespace ...;'。 – chris
是的,打了一個std ::在那裏...... – jdero
不幸的是我的學校讓我們把所有的代碼放在一個文件中。這不是標題。 – Schuyler