write a program for function overloading?

Answer Posted / nekkanti rajesh

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

Is This Answer Correct ?    143 Yes 57 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

class type to basic type conversion

1837


What is encapsulation and abstraction? How are they implemented in C++?

637


What is polymorphism what are the different types of polymorphism?

566


What is difference between class and object with example?

562


What are two types of polymorphism?

611






#include #include #include #include void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

3248


Why oops is important?

611


What does sksksk mean in text slang?

1534


What is protected in oop?

604


What is difference between oop and pop?

613


What is abstraction in oop with example?

644


What is object and class in oops?

588


Are polymorphisms mutations?

701


which feature are not hold visual basic of oop?

1723


Describe these concepts: Polymorphism, Inheritance and Abstraction.

612