1

I'm trying to encapsulate winsock2 inside a class, and I have this member function called bind, which obviously bumps into winsock2.h 's bind function.

class foo {
public:
  void bind();
  void some_function() {
    bind(_sockfd, p->ai_addr, p->ai_addrlen); //error... compiler actually calls foo::bind() instead of the global bind function.
  }

private:
  ...
}

Is there a solution for this? (aside from renaming foo::bind()).

McLovin
  • 3,295
  • 7
  • 32
  • 67

1 Answers1

1

If the function you require is NOT a macro, then you can fully qualify it.

class base {
      int bind(...);
}

class derived : public base {
       int bind(...);
       int someFunction();
}


int derived::someFunction()
{
      base::bind(); // call base class's implementation.
      bind();  // call derived::bind();
      ::bind();  // call global function.
}
mksteve
  • 12,614
  • 3
  • 28
  • 50