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 is overriding in oops?
Why do pointers exist?
Can destructor be overloaded?
Plese get me a perfect C++ program for railway/airway reservation with all details.
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
What type of loop is a for loop?
Can we create object of interface?
What makes a language oop?
hi all..i want to know oops concepts clearly can any1 explain??
How do you define a class in oop?
Why is there no multiple inheritance?
What is object in oops?
Is data hiding and abstraction same?
can inline function declare in private part of class?
What are the benefits of interface?