C++ Program Assignment 1: Inheritance 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 ClassMusic Instrument TrumpetCake Birthday or Wedding CakeAnimal 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. For this step, you pass both instances ( as 2 parameters ) to the method and the method can display the values.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. For this step, you pass only 1 instance but call this method twice. Once passing it the base class object, Once again passing it the derived 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. This includes the .cpp and any .h files.
C++ Program Assignment 1: Inheritance 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 ClassMusic Instrument TrumpetCake Birthday or Wedding CakeAnimal 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. For this step, you pass both instances ( as 2 parameters ) to the method and the method can display the values.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. For this step, you pass only 1 instance but call this method twice. Once passing it the base class object, Once again passing it the derived 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. This includes the .cpp and any .h files.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 12RQ
Related questions
Question
C++ Program
Assignment 1: Inheritance
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 ClassMusic Instrument TrumpetCake Birthday or Wedding CakeAnimal Bear, Cat, or more general such as mammal, fish, etcAssignment:
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.
For this step, you pass both instances ( as 2 parameters ) to the method and the method can display the values.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.
For this step, you pass only 1 instance but call this method twice. Once passing it the base class object, Once again passing it the derived 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. This includes the .cpp and any .h files.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,