I have a header file with the class "Connection" in namespace "ns". The "Connection" class has a function called "connect", which internally uses the Winsock "connect" function. When I want to define the function in the .cpp file, I get error because of wrong parameters. Like it doesn't want to "use" the connect function from the winsock API, just the member function.
Looks like this in the .cpp file: (not final)
bool ns::Connection::connect(char IP[],unsigned short Port)
{
SOCKADDR_IN server_addr;
memset(&server_addr,0,sizeof(SOCKADDR_IN));
server_addr.sin_family = AF_INET;
server_addr.sin_port = Port;
server_addr.sin_addr.s_addr = inet_addr((const char*)IP);
connect(client,&server_addr,0); // here comes the error
}
Use the global namespace to call the correct one:
::connect(client,&server_addr,0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With