Код: Выделить всё
class Inet {
public:
Inet();
int select (int, struct timeval*, fd_set*, fd_set*, fd_set* );
};
class Server : Inet{
public:
void run();
};Inet.cpp
Код: Выделить всё
int Inet::select(int sockfd, struct timeval * tval, fd_set* readfds, fd_set* writefds = NULL, fd_set* exceptfds = NULL) {
int rc = ::select(sockfd, readfds, writefds, exceptfds, tval);
if (rc < 0) {
logs.error("select() failed");
throw Failed();
}
if (rc == 0) {
logs.error("select() timed out.");
throw TimedOut();
}
return rc;
}Server.cpp
Код: Выделить всё
void Server::run() {
//code
this->select(socketMax + 1, &tval, &masterSet);
//code
}Проблема следующая: Компилятор не хочет компилировать это, т.к. он думает, что переменных по умолчанию нет.
Как быть в такой ситуации? Переносить код в хеадер?
Код: Выделить всё
Server.cpp: In member function ‘void Server::run()’:
Server.cpp:77: error: no matching function for call to ‘Server::select(int, timeval*, fd_set*)’
Inet.h:44: note: candidates are: int Inet::select(int, timeval*, fd_set*, fd_set*, fd_set*)