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

i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

2057


what type of questions

1889


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

1896


What is variable example?

783


What is for loop and its syntax?

798


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

2302


write a program to find 2 power of a 5digit number with out using big int and exponent ?

2127


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

1375


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2362


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

1968


What is persistence in oop?

856


what is difference between class template and template class?

2393


What are the 3 pillars of oop?

862


What is difference between pop and oop?

807


What is difference between multiple inheritance and multilevel inheritance?

875