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
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 |
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 |
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 |
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 |
diff between Abstract class Interfaces?
what is the main difference between c and c++?
386 Answers AZTEC, B.Tech, CMC, College School Exams Tests, HCL, IBM, ITM, Khalsa Institute, Microsoft, Oracle, Sanjeevni Institute, TCS, Tech Mahindra, Wipro, ZeOmega,
what are the ways in which a constructors can be called?
What is an orthogonal base class?
pointers are support in C#? if yes then how to use it?
8 Answers Softvision Solution,
what is multithreading in c++ , what is difference between multithreading and singlethreading.
Can we have a private constructor ?
12 Answers HSBC, Ness Technologies, TCS, Wipro,
What are the 3 principles of oop?
what is the abstract class,interface ,its difference with a programatic eg.? hi,recently i went for an interview they ask me what is abstract class ,interface and its difference I said abstract class contain abstact method ,abstract method is a method with no body.Abstract class cannot be instantiated.Abstract class is a base class it required derived class for the implementation of method. Interface is a syntactical contract that all derived class should follow it define properties ,method,events which are known as member of interface. Then They asked me what is the difference between them. I said abstract class interface 1.abstact class can implement method 1.interface cant 2.abstact class can contain constructor, 2.interface cant destructor 3.abstract class cannot support multiple 3.interface support inheritance etc Then they said some different answer I said dont no. Then they ask me when i should make abstract class for an project and when i should make interface. I said if suppose there is two class which must be having method with different logic then we sholud make abstract class. and if suppose we have two class having method .with different logic then we can make interface . Am i correct with my explaination.if not correct me .please provide me that when should we create abstract class and interface and what is difference .please help me
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floating point values.
can we make game by using c