Write a program to use function overloading with user defined function


 

/* Write a program to use function overloading with user defined function*/

 

#include<iostream.h>

#include<conio.h>

class abc

{

public:

void sum(int a,int b)

{

int c;

c=a+b;

cout<<“c=”<<c<<endl;

}

void sum(int a,int b,int c)

{

int d;

d=a+b+c;

cout<<“d=”<<d;

}

};

void main()

{

clrscr();

abc a1;

a1.sum(1,2);

a1.sum(1,2,3);

getch();

}

/* output:

c=3

d=6*/

Related Posts

Comments are closed.