Question: (C++) Consider the following 2D array of objects: Valve sewer[NS_DIR][EW_DIR]; Class Valve has a data member openPercent representing how open the valve is (range is
(C++) Consider the following 2D array of objects:
Valve sewer[NS_DIR][EW_DIR];
Class Valve has a data member openPercent representing how open the valve is (range is 01, 1=fully open). There is a close(double percent) member function to partially or fully close the valve (range is 01, 1=close fully) and a default constructor that makes the valve fully open. Use this array for the next 3 questions.
1. What value will the 3rd element in the array have for its openPercent member?
2. Write loop(s) to set all the valves to be 1/4 open.
3. Suppose NS_DIR is 4 and X_DIM is 3. Recall how 2D arrays are laid out in 1D memory. Which indices would give you the 8th element in memory? (Ans format: sewer[ ][ ])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
