Search code examples
c++naming

C++ external Function Names Overlapping


Im currently working on a class in which i have a method called "connect" inside of it Im also calling the winsock function "connect". This of course causes the compiler to give me an error since it doesn't know what to do with it.

How can I address such a naming Problem in the best way?

I would like to keep my method name since it describes best whats happening.

I have no control over the name of the winsock function "connect" and even if I had I think it would not make much sense to rename it.

Im pretty sure this or something similar has been answered somewhere else but I was too dumb to find it.


Solution

  • While calling winsock standard function you can use scope resolution operator :: before the function name. i.e.

    ::connect(....params....);
    

    And when you want to call your class function you can call the class function in following way -

    this->connect(...params...);
    

    Please note that, I have summarized the solutions suggested int the comments so that future user can get help.