0
votes
namespace std {

    template <> 
    class hash<nGram>{
        public :
            size_t operator()( const nGram &k ) const
            {
                return k.m_hashval;
            }
    };
};

I know I need to add a namespace in somewhere. BUt I don't know where or how. I am very new to this.

Error message : specialization of 'template struct std::tr1::hash' in different namespace ?/?/gcc/V4.1.2/bin/../lib/gcc/sparc-sun-solaris2.10/4.1.2/../../../../include/c++/4.1.2/tr1/functional1:1101: error : from definition of 'template struct std:tr1::hash'

1
one is std::tr1, one is stdbillz
Upgrade your compileruser2249683
I can't. It's the school computersuser3441418

1 Answers

3
votes

Add a namespace tr1 around the template declaration, but inside the std namespace.