Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a base class and also a class that is derived from the base class. The base class needs to very generic, but would expect

Create a base class and also a class that is derived from the base class. The base class needs to very generic, but would expect at least 4 data items. You must code getters and setters but it is OK to code in-line methods in the same file as this class. The derived class should use the public access specification.

The code can be based on anything you like. Examples could be:

 Base Class Derived Class
Music Instrument Trumpet
Cake Birthday or Wedding Cake
Animal Bear, Cat, or more general such as mammal, fish, etc Assignment: 1. In your main code, create an instance variable based on your base class and also an instance variable based on your derived class. 2. Set variable values for each instance. ( Call the setters). 3. Create a method that will display the values in both objects and call that method. This method should not be part of these classes. 4. Create a method named supportsBoth that uses the base class as its method argument. Call this method for both the base instance variable and the derived instance variable and have it display an item that exists solely in the base class object. 

Example:

 Cake myFirstCake;
 // call setters
 BirthdayCake myBirthdayCake;
 // call BirthdayCake setters ( and inherited setters)
 call supportsBoth (myFirstCake) 
 call supportsBoth (myBirthdayCake) 

Deliverable is a working CPP program files.

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

3 The distinction between microeconomics and macroeconomics.

Answered: 1 week ago