Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The definitions of PlainBox, ToyBox and MagicBox are given below: template class PlainBox { private: // Data field ItemType item; public: // Default constructor PlainBox();

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

The definitions of PlainBox, ToyBox and MagicBox are given below: template 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 void setitem(const ItemType\& theltem); //Accessor method to get the value of the data field //Accessor method to get the value of the data field ItemType getltem() 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 setColor(const Color\& theColor); Color getColor() const; I these member functions are inherited from the base class void setitem(const ItemType\& theltem); ItemType getitem() const; *I \}; // end ToyBox template class MagicBox : public PlainBox \{ private: bool firstitemStored; public: MagicBox(); MagicBox(const ItemType\& theltem); void setItem(const ItemType\& theltem); \}; // end MagicBox Which of the following implementations is correct for the setltem member function in MagicBox? [set/tem function in MagicBox magically changes any item to be placed inside to a copy of the first item it ever held.] a) template void MagicBox::setitem(const ItemType\& theltem) \{ if (!firstitemstored) \{ setItem(theltem); firstitemStored = true; // Box now has magic \} // end if \} // end setitem b) None of these answers b) None of these answers c) template void MagicBox>:: setitem(const ItemType\& theltem) item = theltem; firstltemStored = true; // Box now has magic \}// end if \} // end setltem d) template> void MagicBox::setitem(const ItemType\& theltem) \{ if (!firstitemStored) \{ PlainBox>:: :Im lltem(theltem); firstltemStored = true; // Box now has magic \} // end if \} // end setitem

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

Write effective persuasive messages that request favors and action.

Answered: 1 week ago