Question: (c) The following question is referring to the C++ source code in Figure Q1(c). #include using namespace std; class Box private: float length; float height;

 (c) The following question is referring to the C++ source code

(c) The following question is referring to the C++ source code in Figure Q1(c). #include using namespace std; class Box private: float length; float height; float width; public: Box(); void setValues (float, float, float); float getVolume (); ); void Box::setValues (float l, float h, float w) length = 1; height = h; width = w; } float Box::getVolume () { return (length*height*width); int main() { Box cubic; return 0; (i) Figure Q1(c) Write a function definition for constructor to initialized all private member variables to 0.0. [5 marks) -12- SULIT (BEEC 2363) SULIT (ii) In main function, write a C++ code to call setValues() member function and set the private member variables as following; length = 2.4 height = 6.8 width = 10.12 [4 marks] (iii) In main function, write a C++ code to display the volume of cubic object by calling the getVolume () member function. You output console should display as depicted in Figure Q1(c)(iii). Volume is : 165.158 execution time: 0.070 S Process returned @ (@xe) Press any key to continue. Figure Q1(c)(iii). [3 marks]

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!