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
• What are the desirable attributes for memory managment?
What are the three parts of a simple empty class?
What is cohesion in oop?
What are the 4 main oop principles?
what is the sylabus for priliminaries?
What is abstraction in oops with example?
How does polymorphism work?
Is oop better than procedural?
What is difference between polymorphism and inheritance?
Why do pointers exist?
program for insertion ,deletion,sorting in double link list
What does enum stand for?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What is class in oop with example? Why we use classes in oop?