Question: I have one question regarding the bool function ================================= #include using namespace std; class Box{ private: int length; int width; int height; public: Box() :

I have one question regarding the bool function

=================================

#include

using namespace std;

class Box{

private:

int length;

int width;

int height;

public:

Box() : length(0), width(0), height(0) {}

Box(int l, int w, int h): length(l), width(w), height(h) {}

int getLength(){

return length;

}

int getWidth(){

return width;

}

int getHeight(){

return height;

}

void setter(int l, int w, int h){

length = l;

width = w;

height = h;

}

bool empty(){

if (length == 0 || width == 0 || height == 0)

return true;

return false;

}

int getVolume(int length, int width, int height){

int volume = length * width * height;

return volume;

}

void print(int length, int width, int height){

cout << "Length " << length << endl;

cout << "Width: " << width << endl;

cout << "Length: " << length << endl;

}

};

int main(){

Box a, b;

a.setter(0, 0, 0);

cout << "Box #1"<

a.print(a.getLength(), a.getWidth(), a.getHeight());

cout << "Volume: "<

b.setter(3, 2, 4);

cout << "Box #2" << endl;

b.print(b.getLength(), b.getWidth(), b.getHeight());

cout <<"Volume: "<

}

==================================

I have problem understanding this bool function of my code.

bool empty(){

if (length == 0 || width == 0 || height == 0)

return true;

return false;

}

what is return true; next return false;

I'm a begginer of C++, can you explain easily?

Thanks,

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