Write a program to use function overloading with different data type


/* Write a program to use function overloading with different data type*/

#include<iostream.h>

#include<conio.h>

class abc

{

public:

void sum(int a)

{

cout<<“a=”<<a<<endl;

}

void sum(double a)

{

cout<<“a=”<<a<<endl;

}

void sum(char a)

{

cout<<“a=”<<a;

}};

void main()

{

clrscr();

abc a1;

a1.sum(5);

a1.sum(5.2);

a1.sum(‘v’);

getch();

}

/* output:

a=5

a=5.2

a=v*/

Related Posts

Comments are closed.