문제

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