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 constructors in oop?
What is abstraction encapsulation?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is object and class in oops?
What is inheritance in oop?
I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...
Can bst contain duplicates?
What is abstraction in oop with example?
what are the different types of qualifier in java?
How do you achieve polymorphism?
What is cohesion in oop?
c++ program to swap the objects of two different classes
What is a superclass in oop?
How is class defined?
What causes polymorphism?