Question
#include <iostream>
using namespace std;
class Box
{
double length;
double breadth;
double height;
public:
double getVolume(void)
{
return length * breadth * height;
}
void setLength( double len )
{
length = len;
}
void setBreadth( double bre )
{
breadth = bre;
}
void setHeight( double hei )
{
height = hei;
}
Box operator+(const Box& b)
{
Box box;
box.length = this->length + b.length;
box.breadth = this->breadth + b.breadth;
box.height = this->height + b.height;
return box;
}
};
int main( )
{
Box Box1;
Box Box2;
Box Box3;
double volume = 0.0;
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);
volume = Box1.getVolume();
cout << "Volume of Box1 : " << volume <<endl;
volume = Box2.getVolume();
cout << "Volume of Box2 : " << volume <<endl;
Box3 = Box1 + Box2;
volume = Box3.getVolume();
cout << "Volume of Box3 : " << volume <<endl;
return 0;
}
a.
Volume of Box1 : 210 Volume of Box2 : 1560 Volume of Box3 : 5400
b.
Volume of Box1 : 200 Volume of Box2 : 1560 Volume of Box3 : 5400
c.
Volume of Box1 : 210 Volume of Box2 : 1550 Volume of Box3 : 5400
d.
None of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. Operator overloading is
View solution
Q. Which header file is used to declare the complex number?
View solution
Q. How to declare the complex number?
View solution
Q. How many real types are there in complex numbers?
View solution
Q. Which of the following is not a function of complex values?
View solution
Q. What is the return type of the conversion operator?
View solution
Q. Why we use the “dynamic_cast” type conversion?
View solution
Q. How many parameters does a conversion operator may take?
View solution
Q. How types are there in user defined conversion?
View solution
Q. Pick out the correct syntax of operator conversion.
View solution
Q. Which rule will not affect the friend function?
View solution
Q. Which keyword is used to declare the friend function?
View solution
Q. What is the syntax of friend function?
View solution
Q. Pick out the correct statement.
View solution
Q. Where does keyword ‘friend’ should be placed?
View solution
Q. How to store the large objects in c++ if it extents its allocated memory?
View solution
Q. When we are using heap operations what do we need to do to save the memory?
View solution
Q. Which container in c++ will take large objects?
View solution
Q. How to stop your program from eating so much ram?
View solution
Q. Which option is best to eliminate the memory problem?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!
Microprocessor
Understand the heart of your computer with our Microprocessor MCQs. Topics include...
Operating System
Dive deep into the core of computers with our Operating System MCQs. Learn about...