I'd be grateful if someone could double-check this for me and confirm it sounds alright.
class P {
protected:
float p();
public:
virtual float compute() { return p(); };
};
class PI : virtual public P {
protected:
float i();
public:
float compute() { return p() + i(); };
};
class PD : virtual public P {
protected:
float d();
public:
float compute() { return p() + d(); };
};
class PID : public PI, public PD {
public:
float compute() { return p() + i() + d(); };
};
Update(1): Made the sample more coherent, for future generations.
Update(2): Alright one last push before we seal this off; does P::compute() need to be virtual ?
Update(3): Change of plan, how would I achieve this
Controller<PD> p;
or
Controller<PID> pid;
Thanks everyone!