#include #include using namespace std; enum Gender {MALE, FEMALE}; enum Color {WHITE, RED}; class Smurf { public: Smurf(); void Sing(); string GetHeight(); private: string height; protected: string songWords; }; class GenderedSmurf : public Smurf { public: GenderedSmurf(Gender gender); bool IsMaleSmurf(); protected: Gender gender; }; class AgedSmurf : public GenderedSmurf { public: AgedSmurf(Color pants, Gender gender); bool IsPapaSmurf(); void Sing(); private: Color pants; }; // Implementation of Classes Smurf::Smurf() { songWords = "La la, la-la la la, la la-la la la"; height = "Three apples tall"; } void Smurf::Sing() { cout << songWords << endl; } string Smurf::GetHeight() { return height; } GenderedSmurf::GenderedSmurf(Gender gender) { this->gender = gender; } bool GenderedSmurf::IsMaleSmurf() { return (gender == MALE); } AgedSmurf::AgedSmurf(Color pants, Gender gender) : GenderedSmurf(gender) { this->pants = pants; } bool AgedSmurf::IsPapaSmurf() { if (pants == RED && gender == MALE) return true; return false; } void AgedSmurf::Sing() { cout << "Dum diddiley I-O" << endl; } /* Questions: 1) What do the following do? Give the ouput or return value. If it is illegal, say so and explain why. */ int main() { Smurf harmony; GenderedSmurf smurfette(FEMALE); AgedSmurf papa(RED, MALE); harmony.Sing(); cout << harmony.GetHeight() << endl; smurfette.IsMaleSmurf(); smurfette.Sing(); papa.IsPapaSmurf(); smurfette.IsPapaSmurf(); papa.gender = FEMALE; smurfette.pants = WHITE; papa.Sing(); harmony.height = "Two apples tall"; return 0; } /* 2) Which class would you modify if you wanted all Smurfs to be able to change the Song they can sing? 3) Which class would you modify if you wanted Smurfette to be the only smurf which can change its song? 4) How would you change AgedSmurf::IsPapaSmurf() if gender was private instead of protected? */