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

In multilevel inheritance constructors will be executed from the .... class to ... class

2 Answers   ABCO, TCS,


Program to check whether a word starts with a capital letter or not.

1 Answers   Infosys,


what is the difference between <stdio.h>and "stdio.h"?

5 Answers  


What is the diamond problem in inheritance?

0 Answers  


What is the difference between the c++ & java?

2 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }

1 Answers  


1. Define a class.

6 Answers  


What are virtual functions?

2 Answers  


i have to create a view in SQL as like in ORACLE DATA EXPRESS EDITION

2 Answers   CTS,


What are the features of oop?

0 Answers  


what is the basic concept of inheritance?

9 Answers  


What is destructor example?

0 Answers  


Categories