Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 : Define a new exception class named BadVarException that must inherit from the C + + runtime _ error class. This class will

Part 1:
Define a new exception class named BadVarException that must inherit
from the C++ runtime_error class. This class will capture the error case for a degree about the year and the name.
Part 2:
Rewrite the class named VariableInt in the previous exercise to generate a "BadVarException"
whenever the caller tries to create the VariableInt object with the following info:
- invalid variable name: empty or all blanks
- integer value is negative
Part 3:
Write a function named createVariableObject that will accept the variable name and the value
and it will create a VariableInt object dynamically.
If there is an exception, it will check to see if that is a bad integer value, then it will create a simple Variable object.
If the name is bad, it will return nullptr to the caller.
This function must handle all error cases for invalid name such as empty or blanks or invalid value (negative).
This function must use handle errors using try-catch the exception.
This function will return the pointer of the newly created VariableInt or Variable object or nullptr depending on the error it receives.
Note: there is no cin and cout in this function. All input and output must be done in the testing function.
Part 4:
The main() function to test createVariableObject:
Create at least 4 objects with different error cases. You can make up your own data. You do not need to get input from the user.

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

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions

Question

6. Conclude with the same strength as in the introduction

Answered: 1 week ago

Question

7. Prepare an effective outline

Answered: 1 week ago