I'm trying to encapsulate some functions from the C socket library into my own C++ class. I'd like to define a member function that uses the same name as its corresponding C function, but with a different signature. For example, I'd like to write the function
ssize_t MyClass::write(const void *buf);
which makes a call to
ssize_t write(int fd, const void *buf, size_t count);
When I compile I get the following errors
error: no matching function for call to ‘MyClass::write(int&, const char*&, size_t)’
note: candidates are: ssize_t MyClass::write(const char*)
I have the correct #include
statements to make the call to the C socket library, but my definition of a write function seems to be shadowing it. If I change the name of my class defined function to something else, everything seems to work fine.
I'm reasonably sure that changing my function name is going to be my final solution, but could someone tell me the name of the C++ naming rule that causes this behavior? I'd like to read up on it so I know what I'm doing in the future.