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 is encapsulation with example?
What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }
What is an interface in oop?
What is the main purpose of inheritance law?
What is coupling in oop?
which feature are not hold visual basic of oop?
Can abstract class have normal methods?
What is the example of polymorphism?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
Can we create object of interface?
Why do we use encapsulation in oops?
What is overriding vs overloading?
How long to learn object oriented programming?
Give two or more real cenario of virtual function and vertual object
Is html an oop?