Jump to content
  • Advertisement
Sign in to follow this  
rajend3

Help with C++ method and function names

This topic is 3512 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!