How can I call non-member function listen()
(included from sys/socket.h
) from a class which defines a member function with the same name listen()
?
#include <sys/socket.h>
void Socket::listen(int port)
{
...
listen(sock_fd, 10); // this doesn't work
}
Use the scope resolution operator ::
.
void Socket::listen(int port){
//...
::listen(sock_fd, 10);
^^
}
The scope resolution operator ::
is used to identify and disambiguate identifiers used in different scopes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With