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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started