(Package Inheritance Hierarchy) Use the Package inheritance hierarchy created inExercise 19.9 to create a program that displays the address information and calculates the shippingcosts for several Packages. The program should contain a vector of Package pointers to objects ofclasses TwoDayPackage and OvernightPackage. Loop through the vector to process the Packagespolymorphically. For each Package, invoke get functions to obtain the address information of thesender and the recipient, then print the two addresses as they would appear on mailing labels. Also,call each Package’s calculateCost member function and print the result. Keep track of the totalshipping cost for all Packages in the vector, and display this total when the loop terminates.
(Package Inheritance Hierarchy) Use the Package inheritance hierarchy created in
Exercise 19.9 to create a
costs for several Packages. The program should contain a
classes TwoDayPackage and OvernightPackage. Loop through the vector to process the Packages
polymorphically. For each Package, invoke get functions to obtain the address information of the
sender and the recipient, then print the two addresses as they would appear on mailing labels. Also,
call each Package’s calculateCost member function and print the result. Keep track of the total
shipping cost for all Packages in the vector, and display this total when the loop terminates.
Step by step
Solved in 2 steps with 1 images