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

What is overloading in oops?

591


What are the 4 main oop principles?

670


what are the ways in which a constructors can be called?

1572


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1633


Why is oop useful?

593






What is overriding in oop?

544


Is html an oop?

571


What is abstraction in oops with example?

765


What is difference between inheritance and polymorphism?

560


Can an interface inherit a class?

552


What is inheritance write a program to show use of inheritance?

608


Can private class be inherited?

613


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

3550


Can you inherit a private class?

629


What is constructor in oop?

578