Any C++ program can have multiple definitions for the same function name in the same scope. However, the definition of the function must be different from one another by the types and/or the number of arguments in the argument list. Also, you cannot overload function declarations that vary only by return type.
Example:
#include <iostream>
class printData
{
public:
void print(int i) {
cout << "Printing int: " << i << endl;
}
void print(double f) {
cout << "Printing float: " << f << endl;
}
void print(char* c) {
cout << "Printing character: " << c << endl;
}
};
void main(void)
{
printData pd;
// Call print to print integer
pd.print(9);
// Call print to print float
pd.print(100.200);
// Call print to print character
pd.print("Hello C++");
getch();
}