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
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
what type of questions
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
What is variable example?
What is for loop and its syntax?
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
write a program to find 2 power of a 5digit number with out using big int and exponent ?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
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
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
What is persistence in oop?
what is difference between class template and template class?
What are the 3 pillars of oop?
What is difference between pop and oop?
What is difference between multiple inheritance and multilevel inheritance?