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
What are the advantages of polymorphism?
What is the oops and benefits of oops programming?
IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?
What is static in oop?
What is the purpose of enum?
What is class and object in oops?
Can we define a class within the interface?
What are the benefits of oop?
What is the purpose of polymorphism?
Why is abstraction used?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
What do you mean by abstraction?
What is polymorphism programming?
Which method cannot be overridden?
What is the significance of classes in oop?