Code:
#include <iostream>
using namespace std;
int Add(int m, int m)
{
return m+n ;
}
int Subtract(int m, int n)
{
return m - n;
}
int Multiply(int m, int n)
{
return m * n;
}
int main()
{
int m;
cout << "Enter a number: ";
cin >> m;
int n;
cout << "Enter another number: ";
cin >> n;
int nOperation;
do
{
cout << "Enter an operation (0=add, 1=subtract, 2=multiply): ";
cin >> nOperation;
} while (nOperation < 0 || nOperation > 2);
int nResult = 0;
switch (nOperation)
{
case 0: nResult = Add(m, n); break;
case 1: nResult = Subtract(m, n); break;
case 2: nResult = Multiply(m, n); break;
}
cout << "The answer is: " << nResult << endl;
return 0;
}
This program help you to understand the concept of early binding.
Bookmarks