Question

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...

Était-ce utile?

La solution

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 );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top