Question: The Number class has been defined with a single member variable. Extend the functionality of cout by implementing a friend function in Number.cpp that overloads

 The Number class has been defined with a single member variable.

The Number class has been defined with a single member variable.

Extend the functionality of cout by implementing a friend function in Number.cpp that overloads the insertion operator. The overloaded insertion operator should return the output stream and the string "The value is yourNum" (where yourNum is the value of Number's member variable). The main() program will create a Number object and then use cout to display the object.

Hint: the declaration of the friend function is provided in Number.h. What you need to do is build the content of the overloaded function.

Ex: if the value of yourNum is 723, then the output is:

The value is 723

= zyBooks My library > COSC 1437: Programming Fundamentals i home > 108 Lab Overloading the 5 using namespace std; 6 7 class Number ( 8 public: Number(int); 10 void SetNum(int); 11 int Get Num(); 12 //Declared as a friend function to give aperator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!