Jump to content
  • Advertisement
Sign in to follow this  
rajend3

Help with C++ method and function names

This topic is 3658 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!