On 12 July 2011 07:42, eric wrote: > Dear advanced c/g++ programers: > I tried the following code > ----------------------------------------------------------------------------------------- > // Example 6-8 Storing strings in a hast_set > #include <iostream> > #include <string> > #include <hash_set> > using namespace std; > > int main() { > > hash_set<std::string> hsString; > string s = "bravo"; > > hsString.insert(s); > s = "alpha"; > hsString.insert(s); > s = "charlie"; > hsString.insert(s); > > for (hash_set<string>::const_iterator p = hsString.begin(); > p != hsString.end(); ++p) > cout << *p << endl; // Note that these aren't guaranteed > // to be in sorted order > } > --------------------------------------------------------------------------------------------------- > but I got the following compile error(g++ 4.5.2) > ---------------------------------------------------------------- > eric@eric-laptop:~/cppcookbook/ch6$ g++ -Wno-deprecated Example6-8.cpp > Example6-8.cpp: In function ‘int main()’: > Example6-8.cpp:9:3: error: ‘hash_set’ was not declared in this scope hash_set is non-standard, so it's not in namespace std. http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-api-4.5/a00055.html Why don't you ask the authors of the book for corrections to the code, or use a different book which has actually been tested with G++ and contains working code?