What i´m doing wrong undefined reference to `GetFirstParam(st

Hello,

whats wrong on this ?

Thanks for help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	std::string cmdstr = "start/next/end";
	std::string cmd = "";
	
	cmd = GetFirstParam(cmdstr, '/');	

std::string GetFirstParam(std::string &param, const char seperator) 
{
	std::string cmd = "";
	uint8_t pos = param->find(seperator);
	if (pos == 0)
	{
		param->erase(0,1);
        pos = param->find(seperator);
	}

	if (pos == -1) { pos = param->length();}
	if (pos > 0)
	{ cmd = param->substr(0, pos);
	  param->erase(0, pos + 1);
	}
	return cmd;
}
  


Error:
undefined reference to `GetFirstParam(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char)'
Where is that function (or its prototype) relative to the call to it - before or after?
you need a function header or to call it after (below, top to bottom) its body.
the header would just be:
std::string GetFirstParam(std::string &param, const char seperator) ;
put that one line above line 1.

Topic archived. No new replies allowed.