Skip to main content

Practice ยท 2 of 3

explicit shuts the trap

Implement class Meters with explicit Meters(double v) storing v privately and double value() const. The test proves Meters m = 3.0; must NOT compile while Meters m{3.0}; must โ€” your class needs exactly one explicit one-argument constructor.

Difficulty: intermediate

Back to lesson: Practice: Classes, constructors, invariants