Create a third resistor


Objective: Practice inheritance and using pointers. Create a program that tests the members of the Resistor Class and Fancy Resistor Class to ensure that they work properly.
Create a derived class named FancyResistorClass by inheriting the ResistorClass.
Begin work on this class by first coding the class declaration. Then code and test the class constructor function. Code and test the rest of the functions one function at a time. To avoid compiler complaints, comment out the member function prototype declarations that have not yet been completed.
The Fancy Resistor Class should include the following members:
Protected Member Variable Specification
char *m_sptrResType A protected member that is a pointer to a character array. This pointer will hold the address of a dynamic character array that contains the resistor's type - Carbon Film, Metal Film, Carbon or Power.

Public Member Functions Specification
FancyResistorClass( char Name [], double nominalResistance, double Tolerance) This is the parameterized constructor, which will accept arguments for the resistor's name, nominal resistance and tolerance.
You will need to use the new operator to allocate memory for a character array variable that will be pointed to by m_sptrResType.
The user will be displayed an menu of resistor types and be prompted to select a type. The menu options will be:
1. Carbon Film
2. Metal Film
3. Carbon
4. Power

The menu must reject bad input data and force the user to enter a correct resistor type selection.
The user's valid selection will then be stored in the resistor type character array as either Carbon Film, Metal Film, Carbon or Power.
Be sure to include an output statement that displays the message "FancyResistorClass Constructor Called"

void DisplayResistor (void) This function will override the the base class function of the same name.
This function will output the resistor's type and call the base class display resistor function.

~FancyResistorClass( ) This is the Fancy Resistor Class destructor function.
This function should prevent memory leaks by deallocating any previously allocated memory.

Be sure to display the message "FancyResistorClass Destructor Called"
Test the base and derived resistor classes by completing the following tasks:

The main() function should instantiate two objects of ResistorClass: oResOne, oResTwo. oResOne should be instantiated using the default constructor and oResTwo should use the parameterized constructor. In using the parameterized constructor simply pass the three required arguments to test if the constructor works correctly.
Create a third resistor that is a FancyResistorClass object. Use the FancyResistorClass parameterized constructor to instantiate this object.
Display the values of each of the resistor objects.
End the program

Request for Solution File

Ask an Expert for Answer!!
Electrical Engineering: Create a third resistor
Reference No:- TGS0429814

Expected delivery within 24 Hours