Question: 1 . What will the following program display on the screen? #include Using namespace std; class Tank { private: int gallons; public: Tank ( )

1. What will the following program display on the screen?
#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 storage[3]={10,20};
for (int index =0; index <3; index++)
cout << storage[index].getGallons()<< endl;
return 0;
}

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 Programming Questions!