Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started