write a program for function overloading?

Answer Posted / riks

#include<iiostream.h>
class overload
{
public:
int sum(int,int);
float sum(float,float);
};
int overload::sum(int num1,int num2)
{
return num1 + num2;
}
}
float overload::sum(float num1,float num2)
{
return num1+ num2
}
}
int main(90
{
overload o1;
cout<<"o1.sum(5.4f,8.6f)<<endl;
cout<<"o1.sum(19,34)<<endl;

Is This Answer Correct ?    39 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What polymorphism means?

828


Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation

1936


what is difference between class template and template class?

2425


How long to learn object oriented programming?

844


What causes polymorphism?

855


What are properties in oop?

836


What is the difference between abstraction and polymorphism?

868


What is debug class?what is trace class? What differences are between them? With examples.

1888


What is use of overloading?

885


write a program to find 2^n+1 ?

1820


Which is better struts or spring?

834


Is data hiding and abstraction same?

796


What is destructor in oop?

818


What is the difference between a constructor and a destructor?

885


What is the oops and benefits of oops programming?

765