Skip to main content

Practice ยท 3 of 3

Composition: a Car HAS an Engine

Implement class Engine with void start(), bool running() const (private bool running_{false};), and class Car that owns an Engine engine_ member plus std::string model_;, with void drive() (starts the engine) and bool ready() const (engine running).

Difficulty: intermediate

Back to lesson: Practice: static members and this