int Tree::Grow() { for (int i = 0; i < m_flowers; i++) { m_apples.push_back(Apple()); } int const temp = m_flowers; m_flowers = 0; return temp; }
int main() { FruitBasket basket; std::cout << "==== FILLING THE BASKET ====\n"; for (int i = 1; i <= 10; ++i) { switch (std::rand() % 3) { case 0: basket.put_in(Apple()); break; case 1: basket.put_in(Banana()); break; case 2: basket.put_in(Kiwi()); break; default: throw nullptr; } } std::cout << "==== EMPTYING THE BASKET ====\n"; while (!basket.empty()) { Apple an_apple; if (basket.take_out(an_apple)) { an_apple.wash(); an_apple.eat(); continue; } Banana a_banana; if (basket.take_out(a_banana)) { a_banana.peel(); a_banana.eat(); continue; } Kiwi a_kiwi; if (basket.take_out(a_kiwi)) { a_kiwi.peel(); a_kiwi.eat(); continue; } std::cout << "don't know how to prepare that fruit\n"; basket.throw_out_one(); } }
//operator Orange() ; operator Orange() const{ return Apple(); }
operator Pear() const{ return Apple(); }