#include <iostream>
#include <string>
#include "StanfordCPPLib/console.h"
usingnamespace std;
/* Constants */
constint HASH_SEED = 5381; /* Starting point for first cycle */
constint HASH_MULTIPLIER = 33; /* Multiplier for each cycle */
constint HASH_MASK = unsigned(-1) >> 1; /* All 1 bits except the sign */
/* Function prototypes */
int hashCode(string key);
/* Main program to test the hash function */
int main() {
string name;
cout << "Please enter your name: ";
getline(cin, name);
int code = hashCode(name);
cout << "The hash code for your name is " << code << "." << endl;
return 0;
}
int hashCode(string str) {
unsigned hash = HASH_SEED;
int nchars = str.length();
for (int i = 0; i < nchars; i++) {
hash = HASH_MULTIPLIER * hash + str[i];
}
return (hash & HASH_MASK);
}
It gives me this error:
andre@ubuntu-Andre:~/Working/Assignment1-linux/0-Warmup$ g++ Warmup.cpp -o a
/tmp/ccawOOKW.o: In function `main':
Warmup.cpp:(.text+0xb): undefined reference to `_mainFlags'
Warmup.cpp:(.text+0x21): undefined reference to `startupMain(int, char**)'
collect2: ld returned 1 exit status
I've found startupMain() which can be found in Assignment1-linux/0-Warmup/StanfordCPPLib/platform.cpp on line 954, and _mainFlags in Assignment1-linux/0-Warmup/StanfordCPPLib/startup.cpp.
Now I am guessing the problem is to link them up, but I've not able to do so even if I #include "private/main.h" in platform.cpp and startup.cpp.