Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago