C++ allows more than one function to have the same name. It only requires that each have a unique parameter list. To differentiate between functions with the same name it converts the internal name of a function to the name mangled version. The internal name consists of the class name, the function name and a list of the parameters. Each c++ compiler has its own way of mangling names. Here is how Borland does the name mangling.
This is a dummy class built into a dll so that I could get the mangled names.
class __export MyClass
{
public:
void test(const int &,double&,const string,const string&);
void test(const int &,double,const string,const string&);
void test(const int &,double);
void test(int,const double)const;
};
Notice that the class name is followed by the function name. As you see in the summary below, x stands for constant. In the first three functions you see that x is inserted just before the type of each const parameter. Notice in the last example, x is inserted before the q. The letter q is first in all the other functions, so it indicates the beginning of the parameter list. The x before the q indicates that the function is constant. Also notice that m indicates a reference parameter. The type of value returned by the function is not included in the mangled name, so it is impossible to create two functions with the same name and parameter list that have different return types. On the other hand it is possible to have two functions with the same parameter list if one is constant and the other isn't.
@MyClass@0test$qmximdx6stringmx6string @MyClass@0test$qmxidx6stringmx6string @MyClass@0test$qmxid @MyClass@0test$xqixd
x-const m-reference q-beginning of the parameters i -int d-double 6string - string (6 letter id)