a member function call an external function with same name

Y

yuanhp_china

I define a class:
class RtServer
{
public:
RtServer();

void init();

void close();

int sockfd;
};


void RtServer::close() {
close(sockfd);
}

Here I tried to call close() which is socket interface. When
compiling, it show the error message below:
no matching function for call to `RtServer::close(int&)'

I appreciate any help.

hp
 
P

peter koch

I define a class:
class RtServer
{
public:
RtServer();

void init();

void close();

int sockfd;

};

void RtServer::close() {
close(sockfd);
The compiler looks for a matching close here - and finds the
memberfunction RtServer::close. When a matching function is found, no
further search is done - and thus the error. You need to qualify the
close call. If the close you want to call resides in the global
namespace, the correct syntax is ::close(sockfd).
}

Here I tried to call close() which is socket interface. When
compiling, it show the error message below:
no matching function for call to `RtServer::close(int&)'


/Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top