Write an operator overloading program to Overload ‘>’
operator so as to find greater among two instances of the
class.
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 |
Why do we use class in oops?
What is the difference between const int *ptr and int const *ptr???
why we are declare the function in the abstract class even though we are declaring it in Derived class?
What are the advantanges of modularity
Can a destructor be called directly?
Have you ever used threads?
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
OOP'S advantages of inheritance include:
What is design patterns in C++?
What is polymorphism programming?
what is data abstraction with example.
In multilevel inheritance constructors will be executed from the .... class to ... class