Write an operator overloading program to Overload ‘>’
operator so as to find greater among two instances of the
class.
Answer / 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 |
What is oops and its features?
how to swap the variables without using temp and operators
What language is oop?
Why multiple inheritance is not allowed?
What type of Job you are providing?
what is the definition of incapsulation
what is the technical or oop name of object?
Why is abstraction needed?
What are the 3 principles of oop?
What is protected in oop?
who is the founder of c++?
What is Dynamic Polymorphism?