Question: In C++ Please: Problem 1. (100 points) Compute the perimeter of a shape using the virtual function. Write a shape class and its derived classes,
In C++ Please:

Problem 1. (100 points) Compute the perimeter of a shape using the virtual function. Write a "shape" class and its derived classes, i.e., "square" and "circle". Both derived classes have a "inputO" function asking user to enter width or radius of a shape and a "comput prmt(O" function to compute the perimeter of a shape. Assume the "main()" function has a pointer defined as "shape* ptrsp", using virtual functions in the base class "shape" allows calling the proper "inputO" and "comput prmt()" function based on the content of the pointer "ptrsp". For instance, if "ptrsp new square;", "ptrsp input()', and "ptrsp-comput-prmt()" will call the corresponding functions in the "square clasS 0 Specific requirements are as follows 1. (30 points) Create the base class "shape" and the derived classes "square" and "circle". 2. (40 points) Use virtual functions in the base class. 3. (30 points) The code can compute square and circle perimeters by calling ptspcomput-prmt in the main function, in which "ptrsp" is a shape type pointer, and print out the
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
