Alogarithm steps:
Step 1: create the class loc.
Step 2: Declare the constructor loc .which initialize the member variables.
Step 3: Declare the member operator functions with the keyword operator.
Step 4: Define the user specified operator’s behavior in operator function definitions.
Step 5: Create the objects for the class loc.
Step 6: Use the user defined operators for objects.
Step 7: Monitoring the output values.
CPP Program For Unary Operator Overloading
#include
class loc
{
int longtitude,latitude;
public:
loc();
loc(int lg,int lt)
{
longtitude = lg;
latitude=lt;
}
void show()
{
cout<
SAMPLE INPUT AND OUTPUT:
10 20
5 30
11 21
12 22
12 22
90 90
90 90
|