Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Questions about the PlainBox , ToyBox and MagicBox . x and MagicBox are given below: class PlainBox { private: // Data field ItemType item; public:
Questions about the PlainBox , ToyBox and MagicBox . x and MagicBox are given below: class PlainBox \{ private: // Data field ItemType item; public: // Default constructor PlainBox(); // Parameterized constructor PlainBox(const ItemType\& theltem); //Mutator method that can change the value of the data field // Mutator method that can change the value of the data field void setItem(const ItemType\& theltem); //Accessor method to get the value of the data field ItemType getitem() const; \}; // end PlainBox enum Color \{BLACK, RED, BLUE, GREEN, YELLOW, WHITE\}; template class ToyBox : public PlainBox \{ private: Color boxColor; public: ToyBox(); ToyBox(const Color\& theColor); ToyBox(const ItemType\& theltem, const Color\& theColor); void setColorlconst Color\& theColor). ToyBox(const ItemType\& theltem, const Color\& theColor); void setColor(const Color\& theColor); Color getColor() const; I these member functions are inherited from the hase class void setitem(const ItemType\& theltem); ItemType getitem() const; / \}; // end ToyBox template class MagicBox : public PlainBox \{ private: bool firstltemStored; public: MagicBox(); MagicBox(const ItemType\& theltem); bool firstltemStored; public: MagicBox(); MagicBox(const ItemType\& theltem); void setitem(const ItemType\& theltem); end MagicBox uestion 3 (5 points) Which of the following implementations is correct for the constructor in ToyBox? a) template ToyBox::ToyBox(const ItemType\& theltem, const Color\& theColor) \{ PlainBox> (); PlainBox>: :setItem(theltem); boxColor = theColor; \}// end constructor \} // end constructor b) template> ToyBox>:: ToyBox(const ItemType\& theltem, const Color\& theColor) \{ boxColor = the Color \} // c) None of these answers d) template> ToyBox::ToyBox(const ItemType\& theltem, const Color\& theColor) \{ item = theltem; boxColor = theColor; \} // end constructor
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started