Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create method with same name of system function?

I'm new to c++ and have to create class for handling sockets. This class has a method named listen() and in this method need calling listen function to socket (for example see below) but method listen hiding listen function how to solve it ?

void CTCPBlockingSocket::listen() {
     listen(server_socket,5); 
}
like image 818
MohsenTi Avatar asked Apr 06 '26 23:04

MohsenTi


1 Answers

Use the :: operator to specify you want the listen name which is in the global scope, not in a class or namespace.

void CTCPBlockingSocket::listen() {
     ::listen(server_socket,5); 
}
like image 126
aschepler Avatar answered Apr 09 '26 14:04

aschepler