write a program in c++ to overload the function add (s1,s2)
where s1 and s2 are integers and floating point values.

Answer Posted / deepa mathur

include <iostream.h>

void add (int s1, int s2)
{
int s3;
s3= s1 + s2;
cout<<"sum of 2 no. is= "<< s3;
}

void add (float s1, float s2)
{
float s3;
s3 = s1 + s2;
cout<<" sum of 2 no. is= "<< s3;
}

void main
{
void add (int a, int b);
void add (float a, float b);
add(30, 20);
add (30.5, 56.7);
getch();
}

Is This Answer Correct ?    47 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

explain sub-type and sub class? atleast u have differ it into 4 points?

1840


What is meant by multiple inheritance?

742


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

1839


What polymorphism means?

624


Why do we use inheritance?

630






What is the renewal class?

2171


Why is polymorphism used?

588


How do you define a class in oop?

633


What is basic concept of oop?

706


What is stream in oop?

843


Why do we need oop?

672


Describe these concepts: Polymorphism, Inheritance and Abstraction.

616


What is the difference between procedural programming and oops?

561


what is the drawback of classical methods in oops?

2924


Which language is not a true object oriented programming language?

646