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

Can we override main method?

1 Answers  


What is overloading in oop?

1 Answers  


What are the advantanges of modularity

2 Answers  


What are two types of polymorphism?

1 Answers  


what is polymorphism?

4 Answers  


This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.

1 Answers  


how can we design a magic square in c++?or suggest me the basic idea of it.

3 Answers  


What is encapsulation selenium?

1 Answers  


What is class encapsulation?

1 Answers  


why function overloading is not called as pure polymorphism?

2 Answers  


What type of loop is a for loop?

1 Answers  


what is multi level inheritance give n example ?

13 Answers   HDFC, Hulas Steel, Ness Technologies,


Categories