So I have a class that is defined as below:

class Socket {
public:
    Socket();
    virtual ~Socket();

    int open();
    void close();

private:
    int mHandle;
    int mState;
};

Then I implement the close() method as such:

void Socket::close()
{
    if (mHandle!=0)
        close(mHandle);
}

The "close(mHandle)" inside my close is the one defined in and AFAIK it is not within any namespace.

To workaround I renamed my close to something else, but there gotta be some other way...

有帮助吗?

解决方案

Name lookup ends as soon as at least one function is found. You can qualify the name so it starts looking in the right place:

::close( mHandle );

Or declare the name locally so lookup bypasses the class members:

using ::close;
close( mHandle );
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top