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


Please Help Members By Posting Answers For Below Questions

What are constructors in oop?

587


What is abstraction encapsulation?

653


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2002


What is object and class in oops?

582


What is inheritance in oop?

597






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...

1622


Can bst contain duplicates?

664


What is abstraction in oop with example?

642


what are the different types of qualifier in java?

1836


How do you achieve polymorphism?

607


What is cohesion in oop?

617


c++ program to swap the objects of two different classes

1756


What is a superclass in oop?

665


How is class defined?

580


What causes polymorphism?

568