Semester : SEMESTER 6
Subject : Object Oriented Programming
Year : 2018
Term : MARCH
Scheme : 2015 Full Time
Course Code : EC 312
Page:12
It provides multiple definitions of the function by changing signature i.e changing
number of parameters, change datatype of parameters, return type doesn’t play
anyrole.
ഭ |tcan be done in base as well as derived class.
= Example:
ا
void area(int a);
void area(int a, int b);
// CPP program to illustrate
// Function Overloading
#include
using namespace std;
// overloaded functions
void test (int) 7 void
test (float);
voidtest(int, float);
int main ()
{ inta = 5;
floatb = 5.5;
// Overloaded functions
// with different type and
// number of parameters
test(a); test (5) 7
test(a, b);
return 0;
// Method 1
void test (int var)
{
cout << "Integer number: "<< var << endl;
// Method 2 void
test (float var)
{
cout << "Float number: "<< var << endl;
// Method 3
voidtest(int 7321, float var2)
{
cout << "Integer number: "<< varl;
cout << " and float number:" << var2;