OOP 313304 Practical No.19: Write programs to overload the unary operator using- The member function and Friend function
The concept of operator overloading helps to assign a new meaning to the existing operator and helps to extend the concept of polymorphism.
OOP 313304 Practical No.19 Exercise:
1. What is function overloading and operator overloading?
Answer:
2. State output of the following code:
Answer:
Output:
F: -11 I: -10
F: 5 I: -11
feet and inches are inverted for both D1 and D2.D1 changes from (11, 10) to (-11, -10), and D2 changes from (-5, 11) to (5, -11).3. Overload the unary operator –(minus) using member function and friend function
Answer:
Result
The result of the above C++ codes is that the
Distance objects' feet and inches values are negated when the unary minus operator is applied, resulting in F: -11 I: -10 and F: 5 I: -11 being displayed.Practical Related Questions
1. Write a C++ program to overload unary operators (++) increment and (--) decrement by using the member function and friend function.
Answer:
2. Write a C++ program to find the area of various geometrical shapes by function overloading. (eg. Area of circle, circumference of circle, etc...)
Answer:
3.Complete the following table:
Answer:
Conclusion
We Successfully completed OOP 313304 Practical No.19 and Wrote programs to overload the unary operator using- Member function and Friend function.


