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
Why do we use oop?
write a program to find 2^n+1 ?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What is a class and object? What is abstraction encapsulation? Why is there no multiple inheritance? What is overriding in oop? What is difference between data abstraction and encapsulation? Which type does string inherit from? What is meant by multiple inheritance? What is abstract class in oops? How does polymorphism work? What is solid in oops? What are main features of oop? Templates mean