Write an operator overloading program to Overload ‘>’
operator so as to find greater among two instances of the
class.



Write an operator overloading program to Overload ‘>’ operator so as to find greater among..

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

Post New Answer

More OOPS Interview Questions

What is the benefit of oop?

0 Answers  


What is polymorphism what is it for and how is it used?

0 Answers  


Which is not an object oriented programming language?

0 Answers  


What is inheritance write a program to show use of inheritance?

0 Answers  


What are the features of oop?

0 Answers  






What is persistence in oop?

0 Answers  


What is advantage of inheritance?

0 Answers  


why the argument is passed by reference to a copy constructor?example?

2 Answers  


Which is faster post increment or pre increment ? and in which cases should u use either - to increase speed?

4 Answers   EA Electronic Arts,


What is virtual constructors/destructors?

4 Answers   IBS,


all about pointers

2 Answers  


What is property in oops?

0 Answers  


Categories