Method names

Hi allz, i come from pure C, just begun C++ by few days.

I have some questions about methods definitions. I'm implementing a Socket class on linux systems. Here's the problem: let's suppose we have a global function, called connect() and I want to name a method function in the class, with the same name.
1
2
3
4
5
6
7
8
9
10
11
12
#include <sys/socket.h>  /* Here's defined connect() */

class Socket {

public:
    void connect()   /*  the method */
    {
        connect(sd, addr, len);   /* here I mean to call the global function */
         ....
    }
.....
}

As you can figure, the compiler gives me error because it "thinks" i want to call the class method.
Is there any solution? To name that method in such that way is necessary because it's standard and intuitive, i can't have aliases for methods like "connect","bind","listen" etc...

P.S. Pardon my poor English :)
Last edited on
closed account (z05DSL3A)
The :: (scope resolution) operator is used to qualify hidden names so that you can still use them.
1
2
3
4
5
6
7
8
9
10
11
12
#include <sys/socket.h>  /* Here's defined connect() */

class Socket {

public:
    void connect()   /*  the method */
    {
        ::connect(sd, addr, len);   /* here I mean to call the global function */
         ....
    }
.....
}
Last edited on
Thanks
Topic archived. No new replies allowed.