Sign in to follow this  

Help with C++ method and function names

This topic is 3298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a C++ class ServerSocket which has a method called accept. The accept method calls the accept function but this gives me an error. It tries to execute a version of accept that is part of class definition instead. Is there a way to run the function accept versus the classes method?
int ServerSocket::accept()
{
	int newfd;
	socklen_t size = sizeof(clientAddr);

        //call to the accept function
	if( (newfd = accept(sockfd, (struct sockaddr *)&clientAddr, &size)) == -1)
	{
		return -1;
	}

        return newfd;

}

Share this post


Link to post
Share on other sites
Use the scope resolution operator to indicate that you'd like the accept method from the global scope: ::accept()

Additionally, consider that the need for an accept() member functions suggests that your socket class is perhaps too low level, and you should improve its overall design and eliminate the function.

Share this post


Link to post
Share on other sites

This topic is 3298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this