write a program in c++ to overload the function add (s1,s2)
where s1 and s2 are integers and floating point values.

Answers were Sorted based on User's Feedback



write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / deepa mathur

include <iostream.h>

void add (int s1, int s2)
{
int s3;
s3= s1 + s2;
cout<<"sum of 2 no. is= "<< s3;
}

void add (float s1, float s2)
{
float s3;
s3 = s1 + s2;
cout<<" sum of 2 no. is= "<< s3;
}

void main
{
void add (int a, int b);
void add (float a, float b);
add(30, 20);
add (30.5, 56.7);
getch();
}

Is This Answer Correct ?    47 Yes 20 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / rose

include<iostream.h>

class overload
{
void add (int a, int b){
int c;
int c= a+b;
}
void add( float a,float b){
double c;
double c = a+b;}
}
void main()
{overload o = new overload();
o.add(10,20);
o.add(1.2,34.56);
getch();
}

Is This Answer Correct ?    14 Yes 10 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / vaibhav munde

#include<iostream.h>
#include<conio.h>
int add(int s1,int s2)
{
return(s1+s2);
}
float add(float a,float b)
{
return(a+b);
}
void main()
{
int s,s1,s2;
float a,b,c;
clrscr();
cout<<"\n Enter two integer number:";
cin>>s1>>s2;
s=add(s1,s2);
cout<<"Addition of two Integer number:"<<s;
out<<"\n Enter two float number:";
cin>>a>>b;
c=add(a,b);
cout<<"Addition of two Float number:"<<c;
getch();

}

Is This Answer Correct ?    12 Yes 8 No

write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floati..

Answer / 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

More OOPS Interview Questions

What is polymorphism what are the different types of polymorphism?

0 Answers  


1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


What is object and example?

0 Answers  


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(); }

0 Answers   SRA,


In multiple inheritance , to create sub class object , is there need to create objects for its superclasses??? in java and c++ both. Actually i have some information that is , all available members from its superclasses , memory created in subclass obj , so no need to create object for its superclasses...??? Thanks in Advance

1 Answers  






What is abstraction in oops with example?

0 Answers  


What are the important components of cohesion?

0 Answers  


What type of Job you are providing?

0 Answers  


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).

0 Answers  


What is polymorphism in oops?

0 Answers  


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

0 Answers  


What is difference between new and malloc?

7 Answers   emc2,


Categories