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 enum a class?
What is the importance of oop?
What is overriding in oop?
What is oops concept with example?
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).
Can main method override?
What is meant by oops concept?
What is destructor give example?
Are polymorphisms mutations?
What is meant by multiple inheritance?
What is the example of polymorphism?
Can private class be inherited?
What are the benefits of oop?
What is constructor overloading in oop?
What are oops functions?