gfvalvo:
I’ll try to come up with a more concrete example.
I want friends, but I want them to be nice guys (I'll befriend a dunce, too).
If someone is a Big Jerk, I've got to change them before I let them be my friend:
enum HumanTypes{
NICE_GUY,
BIG_JERK,
DUNCE,
};
class HumanBeing{
public:
HumanBeing(HumanTypes _type){type = _type;}
HumanTypes type;
private:
};
class MyFriends : public HumanBeing{
public:
MyFriends(HumanTypes tp) : HumanBeing(tp == BIG_JERK? NICE_GUY : tp){}
void getFreindType(void){
switch (type)
{
case NICE_GUY:
Serial.println(F("Nice Guy"));
break;
case BIG_JERK:
Serial.println(F("Big Jerk"));
break;
case DUNCE:
Serial.println(F("Dunce"));
break;
}
}
private:
};
MyFriends tom(NICE_GUY);
MyFriends john(BIG_JERK);
MyFriends billy(DUNCE);
void setup()
{
Serial.begin(9600);
tom.getFreindType();
john.getFreindType();
billy.getFreindType();
}
void loop() {
}
now that he's my friend, john is a nice guy!