MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / BCD

Class BCD

06.12-bcd0/main.cpp:7–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <cassert>
6
7class BCD {
8public:
9 BCD(int v)
10 : mValue{Adjust(v)}
11 {}
12
13 // #A Make BCD convertible to int
14 operator int() const { return mValue; }
15
16 // #B Provide at least equality comparison
17 bool operator==(const BCD& rhs) const
18 {
19 return rhs.mValue == mValue;
20 }
21
22 bool operator!=(const BCD& rhs) const
23 {
24 return not(*this == rhs);
25 }
26
27private:
28 int mValue;
29
30 static int Adjust(int v);
31};
32
33int BCD::Adjust(int v)
34{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected