Skip to main content
GameDev.net gamedev.net
🔒 Locked

Help with C++ method and function names

Started by rajend3 Dec 4, 2008 at 2:11 PM 1 replies 900+ views
Original Post
rajend3
rajend3
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;

}
Mantear
Mantear
Try calling "::accept()"
jpetrie
jpetrie
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.