class Bot{
private:
char *serveradr;
public:
char *get_serveradr();
char set_serveradr(char *server);
void servcon();
};
char Bot::set_serveradr(char *server)
{
serveradr = server;
}
char *Bot::get_serveradr()
{
return serveradr;
void servcon()
{
sin.sin_addr.s_addr = inet_addr(this.get_serveradr());
}
invalid use of `this’ in non-member function
Sorry for such a question but I’ve searched and know this is how it should be done but I’m not sure what I’m doing wrong.
You need to fully qualify the name of the member function defintion:
Otherwise, it is treated as a free standing function which do not have a
thispointer.As this is C++, use a
std::stringinstead of achar*. The argument passed to theBot::set_serveradr()method must outliveBotwhich is error prone (and who is responsible fordelete[]ing it?). You can access achar*usingstd::string::c_str()method.