I've been banging my head against the wall for the past while trying to figure this out. I want to use this function that I got from stack overflow with these function parameters:
void split(const string& str, const string& delimiters, vector<string>& tokens);
I define it in the header file of my ServerHandler class (ServerHandler.h):
public:
ServerHandler();
~ServerHandler();
void split(const string& str, const string& delimiters, vector<string>& tokens);
void handleRequest(int client, string request);
void handlePutRequest(string request);
bool isValidPutRequest(vector<string> requestTokens);
I put it in my ServerHandler.cc class:
void split(const string& str, const string& delimiters, vector<string>& tokens)
{
...
}
Then I try to call it from my method where I define the two strings and the vector object:
vector<string> requestTokens;
...
string firstHalf;
firstHalf = "tell mike hello!";
...
string spaceDelimiter;
spaceDelimiter = " ";
...
split(firstHalf, spaceDelimiter, requestTokens); // Throws compiler error here
How do I fix this compiler error?
EDIT:
This is the compiler error:
ServerHandler.cc:(.text+0x674): undefined reference to `ServerHandler::split(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> >&)'