C++ examples for Function:Function Return
Calculating Values at Compile Time
#include <iostream> #include <string> using namespace std; unsigned int SDBMHash(const std::string& key) { unsigned int result{ 0 }; for (unsigned int character : key) {/* w w w . j a v a 2s .c o m*/ result = character + (result << 6) + (result << 16) - result; } return result; } int main(int argc, char* argv[]) { std::string data{ "data test" }; unsigned int sdbmHash{ SDBMHash(data) }; cout << "The hash of " << data << " is " << sdbmHash; return 0; }