I have the following classes:
class ServoPart {
protected:
virtual void doJob(byte* job) = 0;
private:
bool moving;
Servo servo;
};
// the following classes only have a constructor so I can use two ServoParts to inherit from
class Major: public ServoPart {};
class Minor: public ServoPart {};
class Arm: public Major, public Minor {
private:
void move() {
// do stuff
if (target == current) {
moving = false;
}
};
public:
void doJob(byte* job) {/* do stuff */};
};
I can't use virtual inheritance (I think) because the Major and Minor need to control one servo each which can't be the same. However, when the Arm is done moving, it should set the moving member to false. Intellisense shows ServoPart::moving, when im typing moving.
Would this access of moving be ambiguous? If yes, how can I fix this? Is my assumption about virtual inheritance, that I can't use it because I have two different servos, correct?
movingstate for both, Major and Minor, and combine them when checking the status. I'll reconsider if I keep getting problems like this thoughdoJobI updated my answer again. Having a virtual function is important information that changes the nature. Be careful not to over-simplify the sample code!