- C 13 13 Shape Hierarchy Implement The Shape Hierarchy Designed In Exercise 12 7 Which Is Based On The Hierarchy In 1 (20.31 KiB) Viewed 35 times
C++ 13.13 (Shape Hierarchy) Implement the Shape hierarchy designed in Exercise 12.7 (which is based on the hierarchy in
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
C++ 13.13 (Shape Hierarchy) Implement the Shape hierarchy designed in Exercise 12.7 (which is based on the hierarchy in
C++ 13.13 (Shape Hierarchy) Implement the Shape hierarchy designed in Exercise 12.7 (which is based on the hierarchy in Fig 12.3). Each TwoDimensionalShape should contain function getArea to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have mem ber functions getarea and getVolume to calculate the surface area and volume, respectively, of the three-dimensional shape. Create a program that uses a vector of Shape pointers to objects of each concrete class in the hierarchy. The program should print the object to which each vector element points. Also, in the loop that processes all the shapes in the vector, determine whether each shape is a TwoDimensional Shape or a ThreeDimensionalShape. If a shape is a TwoDimensionalShape, dis- play its area. If a shape is a ThreeDimensionalShape, display its area and volume.