C++中的HasySub是如何工作的? 我不知道如何在C++中使用HasySub。我对这门语言非常陌生,所以我不知道怎么做很多事情。如何使用SGI哈希_集扩展,使编译器最终编译无误?这是我的头文件: #ifndef _GAME1_H #define _GAME1_H #include "card.h" #include "deck.h" #include <ext/hash_set> const unsigned int TRIALS = 10; class Game1 { private: // Card::Value is defined in card.h as a public enum: // enum Value { NullCard, Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; std::hash_set<Card::Value> *map; // does this really need to be a pointer? public: Game1(); bool isPair(); bool isFlush(); void returnToDeck(); }; #endif

C++中的HasySub是如何工作的? 我不知道如何在C++中使用HasySub。我对这门语言非常陌生,所以我不知道怎么做很多事情。如何使用SGI哈希_集扩展,使编译器最终编译无误?这是我的头文件: #ifndef _GAME1_H #define _GAME1_H #include "card.h" #include "deck.h" #include <ext/hash_set> const unsigned int TRIALS = 10; class Game1 { private: // Card::Value is defined in card.h as a public enum: // enum Value { NullCard, Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }; std::hash_set<Card::Value> *map; // does this really need to be a pointer? public: Game1(); bool isPair(); bool isFlush(); void returnToDeck(); }; #endif,c++,hashset,gcc3,C++,Hashset,Gcc3,当我尝试编译时,我得到: In file included from game1.cpp:9: game1.h:13: error: using-declaration for non-member at class scope game1.h:13: error: expected `;' before '<' token make: *** [game1.o] Error 1 我不知道在类范围中对非成员使用声明意味着什么。 为什么编译器会抱怨预期的“;”在“之前,我认为您应该将地图声

当我尝试编译时,我得到:

In file included from game1.cpp:9:
game1.h:13: error: using-declaration for non-member at class scope
game1.h:13: error: expected `;' before '<' token
make: *** [game1.o] Error 1
我不知道在类范围中对非成员使用声明意味着什么。
为什么编译器会抱怨预期的“;”在“之前,我认为您应该将地图声明为

根据


此外,map不是变量的好名称,因为它是标准类的名称。虽然它不应该是这里编译错误的原因。

我使用的是gcc 3.4.6亲爱的上帝…@ildjarn我知道。。。它在我的学校服务器上,所以我对此无能为力。为什么不使用std::set?如果这是一个作业,请告诉你的老师他们需要更新。哈希集很久以前就被弃用了。我们今天使用无序的_集,它是标准化的,并带有最新的GCC。@djthoms No,std::set是一个二叉树,因此它将是Olg N用于查找。
// answering your other question, most likely it doesn't have to be a pointer.
__gnu_cxx::hash_set<Card::Value> map;