-
What is the output of this program?
#include
using namespace std;
class BoxExample
{
double L;
double B;
double H;
public:
double getVol(void)
{
return L * B * H;
}
void setL( double length )
{
L = length;
}
void setB( double breadth )
{
B = breadth;
}
void setH( double height )
{
H = height;
}
BoxExample operator+(const BoxExample& b)
{
BoxExample box;
box.L = this->L + b.L;
box.B = this->B + b.B;
box.H = this->H + b.H;
return box;
}
};
int main( )
{
BoxExample BoxA,BoxB,BoxC;
double vol = 0.0;
BoxA.setL(6.0);
BoxA.setB(7.0);
BoxA.setH(5.0);
BoxB.setL(12.0);
BoxB.setB(13.0);
BoxB.setH(10.0);
vol = BoxA.getVol();
cout << "Volume of BoxA : " << vol <vol = BoxB.getVol();
cout << "Volume of BoxB : " << vol <BoxC = BoxA + BoxB;
vol = BoxC.getVol();
cout << "Volume of BoxC : " << vol <return 0;
}
-
- Volume of BoxA : 1540
Volume of BoxB : 3744
Volume of BoxC : 60 - Volume of BoxA : 60
Volume of BoxB : 1540
Volume of BoxC : 3744 - Volume of BoxA : 3744
Volume of BoxB : 1540
Volume of BoxC : 60 - Volume of BoxA : 60
Volume of BoxB : 3744
Volume of BoxC : 1540 - None of these
- Volume of BoxA : 1540
Correct Option: B
In this program, we finding the boxC area by adding boxA and boxB.