template typename> struct crtp { T& underlying() { return static_cast(*this); } T const& underlying() const { return static_cast(*this); } }; template struct Scale : public crtp { void scale(double multiplicator) { this->underlying().setValue(this->underlying().getValue() * multiplicator); } }; template struct Square : public crtp { void square() { this->underlying().setValue(this->underlying().getValue() * this->underlying().getValue()); } }; class Sensitivity : public Scale, public Square { public: double getValue() const { return value_; } void setValue(double value) { value_ = value; } private: double value_ = 0.; }; int main() { Sensitivity s; s.setValue(10.); s.scale(2.); return 0; }