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 type of loop is a for loop?
What is data binding in oops?
Why do we need oop?
What causes polymorphism?
What is coupling in oop?
any one please tell me the purpose of operator overloading
Where You Can Use Interface in your Project
What are the 4 pillars of oop?
How do you define a class in oop?
What is this pointer in oop?
What is a function in oop?
What is multilevel inheritance?
How to improve object oriented design skills?
• What are the desirable attributes for memory managment?
What does no cap mean?