Write an operator overloading program to Overload ‘>’
operator so as to find greater among two instances of the
class.
Answer Posted / niraj verma
# include<iosteam.h>
# include<conio.h>
Class Greatest
{
Private:
Int x;
Public:
Void getdata
{
Cout<<” Enter any number”
Cin>>x;
}
Void operator > (greatest obj2)
{
If (x > obj2.x)
{
Cout<<”\n Greatest =”<<obj2.x;
}
Else
{
Cout<<”\n Greatest =”<<x;
}
}
};
Void main ( )
{
Greatest obj1, obj2;
Obj1. getdata ( );
Obj2. getdata ( );
Obj > obj2;
Getch ( );
}
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
program for insertion ,deletion,sorting in double link list
What are main features of oop?
What is coupling in oops?
What is object in oop?
What is overriding in oops?
Why do we use oops?
Is abstract thinking intelligence?
What is the purpose of enum?
What is a class oop?
What is super in oop?
Templates mean
What is constructor overloading in oop?
What is a class in oop?
What are functions in oop?
• What are the desirable attributes for memory managment?