0
#include <iostream>
using namespace std;
 
int main(int argc, char * argv[])
{
        hash<const char*> H;
        cout << "foo() ->" << H("foo()") << endl;
}

compilation error after
g++ -c -g main.cc
is :

main.cc: In function `int main(int, char**)':
main.cc:8: error: `hash' undeclared (first use this function)
main.cc:8: error: (Each undeclared identifier is reported only once for each 
   function it appears in.)
main.cc:8: error: syntax error before `char'
main.cc:9: error: `H' undeclared (first use this function)

why?
thanx

5
Contributors
6
Replies
7
Views
10 Years
Discussion Span
Last Post by vijayan121
0

#include <functional> and use gcc 4.3 with the switch -std=c++0x

#include <iostream>
#include <functional>
using namespace std;
 
int main(int argc, char * argv[])
{
        hash<const char*> H;
        cout << "foo() ->" << H("foo()") << endl;
}
// g++43 -std=c++0x -Wall -c -g main.cc
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.