Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Purpose: Utilize Inheritance General requirements: - All data members must be declared as private - No global variable is allowed to be declared and used
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 :
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 VARisSuccessful
contains that accepts a search string and it will return true if its variable
name contains that string caseinsensitive and false otherwise.
Show how this class being used to create objects and call all its methods and show
how they work.
Part :
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 VARgreeting VALUEHello World!"
override the "contains" method so that it not only searches through the name but also the value of the string.
Part
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 VARcount VALUE
Part
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
The main function:
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.
Show how you test all methods defined in the above classes
for c class please
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started