A
Anonymous
Hi Folks,
I want to wrap the Unix socket library in a C++ class and am having the
following difficulty. I have a method in my C++ class named connect and
within this method I want to call the Unix socket connect function. The
problem is that the compiler complains:
.../common/Socket.h:71: error: no matching function for call to
âSocket::connect(int&, sockaddr*&, int&)â
.../common/Socket.h:37: note: candidates are: void Socket::connect(const
char*, int)
Notice that it is looking within my Socket class for connect(int, sockaddr,
int), but it really should be looking in the C-based socket library. What
I've done as a kludgy fix is to create a forwarding function:
fConnect(int, sockaddr, int) {
connect(int, sockaddr, int);
}
class Socket {
connect() {
fConnect(int, sockaddr, int);
}
}
But I find this to be ugly. Is there a better way to accomplish this,
perhaps my simply specifying which connect I want to call within the class,
instead of having to deal with renaming things?
Thank you.
I want to wrap the Unix socket library in a C++ class and am having the
following difficulty. I have a method in my C++ class named connect and
within this method I want to call the Unix socket connect function. The
problem is that the compiler complains:
.../common/Socket.h:71: error: no matching function for call to
âSocket::connect(int&, sockaddr*&, int&)â
.../common/Socket.h:37: note: candidates are: void Socket::connect(const
char*, int)
Notice that it is looking within my Socket class for connect(int, sockaddr,
int), but it really should be looking in the C-based socket library. What
I've done as a kludgy fix is to create a forwarding function:
fConnect(int, sockaddr, int) {
connect(int, sockaddr, int);
}
class Socket {
connect() {
fConnect(int, sockaddr, int);
}
}
But I find this to be ugly. Is there a better way to accomplish this,
perhaps my simply specifying which connect I want to call within the class,
instead of having to deal with renaming things?
Thank you.