The Best Essay Writing Service

Get started with the best Essay Writing Service around. Simply send us your essay question, and we’ll locate an expertly qualified writer to create an answer like no other. wycieczka do czarnobyla z kijowa po polsku

(Shape Hierarchy) Implement the Shape hierarchy

(Shape Hierarchy) Implement the Shape hierarchy designed in Exercise 20.7 (which is based on the hierarchy in Fig. 20.3). Each Two Dimensional Shape should contain function get Area to calculate the area of the two-dimensional shape. Each Three Dimensional Shape should have member functions get Area and get Volume 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 Two Dimensional Shape or a Three Dimensional Shape. If a shape is a Two Dimensional Shape display its area. If a shape is a Three Dimensional Shape display its area and volume. Exercise 20.7 (Richer Shape Hierarchy) The world of shapes is much richer than the shapes included in the inheritance hierarchy of Fig. 20.3. Write down all the shapes you can think ofboth two-dimensional and three-dimensionaland form them into a more complete Shape hierarchy with as many levels as possible. Your hierarchy should have the base class Shape from which class Two Dimensional Shape and class Three Dimensional Shape are derived. Well use this hierarchy in the exercises of Chapter 21 to process a set of distinct shapes as objects of base-class Shape. (This technique called polymorphism is the subject of Chapter 21.)

Leave a Reply

Your email address will not be published. Required fields are marked (required)