MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / Box

Class Box

Examples/NoModules/Chapter 16/Ex16_09/Box.h:6–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "DimensionError.h"
5
6class Box
7{
8public:
9 Box(double l, double w, double h) : m_length{ l }, m_width{ w }, m_height{ h }
10 {
11 if (l <= 0.0 || w <= 0.0 || h <= 0.0)
12 throw DimensionError{ std::min({l, w, h}) };
13 }
14
15 double volume() const { return m_length * m_width * m_height; }
16private:
17 double m_length{ 1.0 };
18 double m_width{ 1.0 };
19 double m_height{ 1.0 };
20};
21
22#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected