2. Define a new exception class named "VarNameException" that must inherit from the C++ runtime error class. This class will capture the error case for a variable name when it is empty, only blanks or starting with a number. For example, if the user tries to create with a variable name of “", “ ", or "Iname", it will generate an exception and this class should capture the reason and the error value.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
C++ Question 2
1. Define a class named "BoolVariable" that manages a variable name (string)
and a boolean value (true or false). It should not have default constructor.
The class must at least provide the following methods:
o toString() method that can return a string in the following format:
variable-name(variable-boolean-value) such as isSuccessful(true)
o containsIgnoreCase() 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.
2. Define a new exception class named "VarNameException" that must inherit
from the C+H runtime error class. This class will capture the error case for a
variable name when it is empty, only blanks or starting with a number.
For example, if the user tries to create with a variable name of ",
“Iname", it will generate an exception and this class should capture the reason
and the error value.
", or
Transcribed Image Text:1. Define a class named "BoolVariable" that manages a variable name (string) and a boolean value (true or false). It should not have default constructor. The class must at least provide the following methods: o toString() method that can return a string in the following format: variable-name(variable-boolean-value) such as isSuccessful(true) o containsIgnoreCase() 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. 2. Define a new exception class named "VarNameException" that must inherit from the C+H runtime error class. This class will capture the error case for a variable name when it is empty, only blanks or starting with a number. For example, if the user tries to create with a variable name of ", “Iname", it will generate an exception and this class should capture the reason and the error value. ", or
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage