Example 1 #include using namespace std; class Box double length, width, height; public: friend void printWidth (Box box); void setDim (double len, double wid, double hei) { length = len; width = wid;...


H.W: Modify the above program to include a friend fuction called printVolume to display volume of the box. Using C++


Example 1<br>#include <iostream><br>using namespace std;<br>class Box<br>double length, width, height;<br>public:<br>friend void printWidth (Box box);<br>void setDim (double len, double wid, double hei)<br>{<br>length<br>= len;<br>width = wid;<br>height = hei;<br>} ;<br>// Note: printWidth () is not a member function of any class.<br>void printWidth (Box box)<br>{<br>cout <<

Extracted text: Example 1 #include using namespace std; class Box double length, width, height; public: friend void printWidth (Box box); void setDim (double len, double wid, double hei) { length = len; width = wid; height = hei; } ; // Note: printWidth () is not a member function of any class. void printWidth (Box box) { cout < "width="" of="" box="" :="" "="">< box.width="">< endl;="" main="" function="" for="" the="" program="" int="" main="" ()="" {="" box="" box;="" set="" box="" dimensions="" with="" member="" function="" box.setdim="" (15.0,="" 10.0,="" 5);="" use="" friend="" function="" to="" print="" the="" width.="" printwidth="" (box);="" return="">

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here