Question: #include using namespace std; class Tank { private: int gallons; public: Tank() { gallons = 50; } Tank(int gal) { gallons = gal; } int
#include using namespace std; class Tank { private: int gallons; public: Tank() { gallons = 50; } Tank(int gal) { gallons = gal; } int getGallons() { return gallons; } }; int main() { Tank storage1, storage2(4.967), storage3(20); cout << storage1.getGallons() << endl << endl; cout << storage2.getGallons() << endl << endl; cout << storage3.getGallons() << endl << endl; return 0; } 1. Explain the 3 lines of output.
2. Include two mutator functions in the code- one to set the number of gallons for each tank, and one to set the color for each tank. Also write another accessor function to get the colors of the tanks. Then print out accordingly which color of tank has how many gallons. Include your code and the printout you're expecting.
(Note: when you are rewriting the code, you can assume that you're not using any overloaded constructors in your code.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
