Join Our WhatsApp Group Join Subscribe Now!

OOP (313304) Practical No.7: Write program to Implement Friend Function using Two different classes Answer

OOP (313304) manual Practical No.7 answer

 OOP (313304) Practical No.7: Write a program to Implement the Friend Function using Two different classes Answer

The classes and objects help to represent real-life entities with different attributes and related member functions. The use of the friend function allows non-member functions to access the private and protected data of the class.

OOP (313304) Practical No7


Friend Function: A friend function of a class is defined outside that class scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions. friend keyword is used to declare the function as a friend of the class.

OOP (313304) Practical No.7 Exercise:

1. Write a C++ program to exchange the values of two variables using the friend function.

Answer:



2. WAP to create two classes test1 and test2 which stores the marks of a student. Read the value for class objects and calculate the average of two tests using the friend function.

Answer:


Practical Related Questions

1. WAP to declare a class calculation. Display addition, subtraction, multiplication, and division of two numbers. Use the friend function.

Answer:


2. Complete the following table:

Answer:

OOP (313304) Practical No.7


Conclusion

We completed OOP (313304) Practical No.7 in which we wrote various C++ codes for Implement Friend Function using Two different classes and run them correctly.

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.