In this exercise, you create the cone class. The cone class represents a 3-dimensional cone.
In the previous exercise, you used the C++ visual development tools to extend the circle and sphere classes. In this exercise, you use the C++ visual development tools to add the cone class to the project. The cone class, which inherits from the shape3d class, calculates and displays the volume and surface area based on the radius and height of the cone. You can use the C++ visual development tools to add a class to the project, and to add an attribute to a class. To edit the body of the method, double-click the method in the diagram and edit the source code in the code editor.
Add the cone class to the Shapes project
You can add the class to the project by using the C/C++ Project Explorer view. You can identify any inheritance relationships by using the New C++/Class wizard.
To add the cone class to the Shapes project:
You have now added the cone class to the Shapes project. You can use the C++ visual development tools to add classes and attributes to the new class. Your diagram should look similar to the following figure:

The cone class implements the getColor and setColor methods that the base shape class defines.
To add the getColor and setColor methods to the cone class:
The cone class implements the getSize and setSize methods that the base shape class defines. The size field stores the height of the cone.
To add the getSize and setSize methods to the cone class:
The cone class implements the getRadius and setRadius methods that the base shape class defines. The radius field stores the radius of the base of the cone. The application uses the radius to calculate the circumference and the volume of the cone.
To add the getRadius and setRadius methods:
The cone class implements the surface area and volume methods that the shapes3d class defines. The formula that calculates the surface area of a cone is πr² (r + (r2 + h2)1/2). The formula that calculates the volume of a cone is 1/3 x πr²h.
To add the surfaceArea and volume methods to the cone class:
The cone class implements the set and print methods that the base shape class defines.
To add the set and print methods to the cone class:
The cone.cpp class file contains the implementation of the set method, as well as the constructor and destructor. You modify the body of the set method to prompt the user to specify the size and radius of the cone. You must also edit the default constructor to set the initial values of the new cone class.
To edit the cone.cpp file:
Before you can run the application, you must add the include statement to the main.cpp class to include the new cone class. You can run the application and instantiate the new cone class by modifying the main.cpp class.
To run the application: