Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Any comments are greatly appreciated Create a base class call Item and a derived class called Consumable. Create two subclasses of Consumable called

In C++

Any comments are greatly appreciated

Create a base class call Item and a derived class called Consumable. Create two subclasses of Consumable called Juice and Chili. Provide the Item class with 3 private variables called name, weight and value. Provide getter and setter methods for each of these variables. Provide constructors and destructors for each class. Each should display a message notifying the user it has been executed.

In main() Create an array of 10 Item pointers. Use a for loop to assign the first five elements an object from the Juice class. Do the same for the last 5 elements but from the Chili class. Make sure your objects are stored on the heap.

Use the setter methods to set the name of the first and last objects. Dont worry about setting the values for the other objects. Create a global function called crazy() that receives 2 item pointers as parameters. Program this function to swap the names of the two items.

Call the function in main() and pass it the two named objects using pass by pointer. Display the names of the two objects after the swap.

Free up all of the memory that was used by the objects before ending your program.

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

Students also viewed these Databases questions

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago