write a program in c++ to overload the function add (s1,s2)
where s1 and s2 are integers and floating point values.
Answer Posted / shubham hajare
#include "stdafx.h"
#include<iostream>
#include<conio.h>
using namespace std;
class stud
{
public:
void add(int a,int b)
{
cout<<a+b;
}
void add(float a,float b)
{
cout<<a+b;
}
void add(int a,float b)
{
cout<<a+b;
}
};
void main()
{
stud a;
a.add(12,12);
a.add(1.2,1.2);
a.add(12,12.2);
_getch();
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
Is abstract thinking intelligence?
What is the difference between inheritance and polymorphism?
What is abstraction and encapsulation?
Why do while loop is used?
What is class in oop with example?
What is meant by multiple inheritance?
Prepare me a program for the animation of train
What are properties in oop?
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
What is an interface in oop?
What is the main feature of oop?
Whats is abstraction in oops?
What is stream in oop?
Why is static class not inherited?
What are different oops concepts?