Please Login in order to post a comment
What is the input format?? The problem is incomplete
Here is Box It! problem solution in C++ - https://programmingoneonone.com/hackerrank-box-it-solution-in-cpp.html
what needs to be called in the main function? There is no definition of it in the problem, thta is causing the test cases to fail.
C++20 is "broken". One can define the default constructor as
Box() = default;
All members will then be initialized to default value, i.e.: int => 0
int => 0
But if you do that instead of: Box(): l{0}, b{0}, h{0} {}, several testcases will fail.
Box(): l{0}, b{0}, h{0} {}
And the same applies to the default copy constructor. Given that is "clang", the compiler switches are not porperly applied.
Python main learning C++ 🤪
class Box{ private: int l; int b; int h; public: Box(){ l = 0; b = 0; h = 0; } Box(int length, int breadth, int height){ l = length; b = breadth; h = height; } int getLength(){ return l; } int getBreadth(){ return b; } int getHeight(){ return h; } long long CalculateVolume(){ return static_cast<long long>(l)*b*h; } bool operator<(Box& other) const{ if(l < other.l){ return true; } else if(b < other.b && l == other.l){ return true; } else if(h < other.h && b == other.b && l == other.l){ return true; } return false; } friend ostream& operator<<(ostream& os, const Box& other) { os << other.l << " " << other.b << " " << other.h; return os; } };
Seems like cookies are disabled on this browser, please enable them to open this website
What is the input format?? The problem is incomplete
Here is Box It! problem solution in C++ - https://programmingoneonone.com/hackerrank-box-it-solution-in-cpp.html
what needs to be called in the main function? There is no definition of it in the problem, thta is causing the test cases to fail.
C++20 is "broken". One can define the default constructor as
Box() = default;
All members will then be initialized to default value, i.e.:
int => 0
But if you do that instead of:
Box(): l{0}, b{0}, h{0} {}
, several testcases will fail.And the same applies to the default copy constructor. Given that is "clang", the compiler switches are not porperly applied.
Python main learning C++ 🤪