Write a program to use function overloading


 

/* Write a program to use function overloading*/

 

#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(double a,double b)

{

double c;

c=a+b;

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

}

void sum(char a,char b)

{

char c;

c=a+b;

cout<<“c=”<<c;

}

};

void main()

{

clrscr();

abc a1;

a1.sum(5,4);

a1.sum(5.2,6.4);

a1.sum(‘v’,’k’);

getch();

}

/* output:

c=9

c=11.6

c=v*/

Related Posts

Comments are closed.