Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Inheritance Purpose: Utilize Inheritance General requirements: - All data members must be declared as private - No global variable is allowed to be declared and

Inheritance
Purpose: Utilize Inheritance
General requirements:
- All data members must be declared as private
- No global variable is allowed to be declared and used (constants are ok)
- No multiple return statements in one function
- Show how you have tested these functions
- cin and cout are not allowed in these classes and methods. They can only be in main() or testing functions
- These classes should not provide the default constructor.
- You can put all class definitions in one file or multiple files. It's your choice.
Part 1:
Define a class named Variable that manages a variable name (string). It should not provide the default constructor.
The class must at least provide the following methods:
- toString() method that can return a string in the following format:
VAR() such as VAR(isSuccessful)
- contains() that accepts a search string and it will return true if its variable
name contains that string (case-insensitive) and false otherwise.
Show how this class being used to create objects and call all its methods and show
how they work.
Part 2:
Write a new class named VariableString that must inherit from the
"Variable" class. This class manages a variable name (string) and a
value (string). Please note that this class must make use of inheritance.
The class must at least provide the following methods:
- toString() method that can return a string in the following format:
VAR() VALUE()
such as VAR(greeting) VALUE("Hello, World!")
- override the "contains" method so that it not only searches through the name but also the value of the string.
Part 3
Write a new class named VariableInt that must inherit from the
"Variable" class. This class manages a variable name (string) and a
value (integer). Please note that this class must make use of inheritance.
The class must at least provide the following methods:
- toString() method that can return a string in the following format:
VAR() VALUE()
such as VAR(count) VALUE(100)
Part 4
Write a function named findVariables that accepts a vector of Variable
object pointers and a search string. It will return the list of Variable
object pointers that contains that search string.
Please note that the list can contain pointers to Variable, VariableString or VariableInt objects
or any of its derived class objects.
Part 5
The main() function:
1. Build a list of pointers pointing to mixed objects of Variable, VariableString and VariableInt objects
and show your function returns the mix of three different types.
2. Show how you test all methods defined in the above classes.
write in c++ with some comments, and just write the whole code, no exlaining need
Thank you!

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

Students also viewed these Databases questions