Join Our WhatsApp Group Join Subscribe Now!

OOP 313304 Practical No.19: Write programs to overload unary operator using- Member function and Friend function

OOP 313304 Practical No.19: Write programs to overload unary operator using- Member function and Friend function

 OOP 313304 Practical No.19: Write programs to overload the unary operator using- The member function and Friend function

OOP 313304 Practical No.19


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

  • After applying the unary minus operator, the signs of the feet and inches are inverted for both D1 and D2.
  • Therefore, 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.

    About the Author

    Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

    Post a Comment

    Cookie Consent
    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
    Oops!
    It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
    AdBlock Detected!
    We have detected that you are using adblocking plugin in your browser.
    The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
    Site is Blocked
    Sorry! This site is not available in your country.