Question
C++!!!!!!! Class - Friend Functions Class members can access other functions outside of their own member functions called friend functions. 1.Create a class with the
C++!!!!!!!
Class - Friend Functions
Class members can access other functions outside of their own member functions called friend functions.
1.Create a class with the following member variables and functions:
a)Initialize the member variables n1 and n2;
b)Add two numbers and return the sum (n1 + n2)
c)Subtract two numbers and return the difference (n1 n2)
d)Multiply two numbers and return the product (n1 * n2)
e)Divide two numbers and return the dividend (n1 / n2). If n2 is zero, set n2 to 1.
2.The class has several friend functions:
a)Average pass the class object and return the average of n1 and n2
b)Compare1 pass the class object and return the Larger of n1 and n2. If n1 and n2 are equal zero to signal that n1 and n2 are equal
c)Compare2 pass the class object and return the Smaller of n1 and n2. If n1 and n2 are equal zero to signal that n1 and n2 are equal
3.Allow the user to run this as many times as they wish during the applications execution
Output Example:
1 of 2 - Enter First numeric Value: 22.3
2 of 2 - Enter Second numeric Value: 44.5
First Value is 22.3
Second Value is 44.5
22.3 + 44.5 = 66.8
22.3 - 44.5 = -22.2
22.3 X 44.5 = 992.35
22.3 / 44.5 = 0.501124
Average of 66.8 is 33.4
The Larger of 22.3 and 44.5 is 44.5
The Smaller of 22.3 and 44.5 is 22.3
Run this Again (Y or N):
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started