// overload1.cpp By: Aiman Hanna - ©1993-2006 Aiman Hanna // This program illustrates the concept of function overloading. Function overloading // refers to the ability to have different functions with the same name. Although // more than one function have the same name, upon calling any of these functions the // compiler is capable of determining which one of these functions is to be executed. // The compiler performs that by verifying the type of the passed parameters, and find // the function that provides the best match. You should notice that: // 1) If more than one function provide a best match, the compiler will NOT be // able to determine which one of these function should run, so an error is // generated. // 2) The return type is NOT used by the compiler to distinguish between // overloaded functions. As an example, the following is not a correct function // overloading: int fun(int, int); and double fun(int, int); // 3) Although some of the overloaded functions may cause a potential (eventual) // confusion to the compiler, the compiler may allow such function overloading // as long as there are no calls within the program that lead this confusion to // take place. You should always make sure that you use overloaded functions // correctly. // The following programs will illustrate the above points. // Key Points: 1) Function overloading #include "overload1.h" MathOperations::MathOperations( void ) { ires = 0; dres1 = dres2 = 0; } int MathOperations::divide ( int i1, int i2 ) { // divide the 1st passed parameter by the second one, and assign the result to // the private data ires. The function assumes that the second parameter will // never be 0 cout << "\n Executing an integer type division. " << endl; ires = int(i1/i2); cout << " The result of dividing " <