Question: Following java code returns hash code of a string. 

```
String uri = "Some URI"
public int hashCode() {
    return uri.hashCode();
}

```

I want to translate this code to c++. Is there any function availabe in c++ or an easy way to translate this.

Answer: 
In C++03, `boost::hash`. In C++11, `std::hash`.

```
std::hash<std::string>()("foo");

```
Boost provides a hash function:

[boost hash](http://www.boost.org/doc/libs/1_47_0/doc/html/hash.html)

```
#include <boost/functional/hash.hpp>

int hashCode()
{
    boost::hash<std::string> string_hash;

    return string_hash("Hash me");
}

```