Exercise 1: Visualizing the Shapes project

In this exercise, you visualize the C++ Shapes project to view the class hierarchy.

The C++ shapes project contains a set of classes that represents 2-dimensional and 3-dimensional shapes. The shape class is the base class from which every other class inherits. The shape2d class and the shape3d class inherit from the base shape class to represent 2-dimensional and 3-dimensional shapes. Accordingly, each shape inherits from either the 2-dimensional shape class or the 3-dimensional shape class.

Visualizing the base shape classes

You can use the C++ visualizer to view the hierarchy of your application before you extend it. You can better understand the structure of the application by viewing the relationships between the classes. You can also use the visualizer to quickly extend your applications by using the class diagram modeling interface.

Before you begin, you must import the Shapes project. You can import the shapes project from the Samples Gallery, or click See a related sample on the Overview page.

To compile the project, you must have a compatible C++ compiler installed. For more information about C++ compilers, see the online help.

To visualize the base shape classes:
  1. In the C++ perspective, in the C++ Projects Explorer , expand Shapes.
  2. Expand the shape.h class, right-click the Shape class element; then click Visualize > Add to New Diagram File > Class Diagram.
  3. In the C/C++ Project Explorer view, expand shape2d.h, click the shape2d class element, and drag it into the diagram editor.
  4. Expand shape3d.h, click the shape3d class element, and drag it into the diagram editor.
You have now visualized the base classes of the C++ Shapes project. Your diagram should look similar to the following figure:

The base shapes classes are visualized using the C++  visualizer.

Visualizing the circle and sphere classes

You can visualize the shape and circle classes to better view and understand the project hierarchy.

To visualize the circle and sphere classes:
  1. In the C/C++ Project Explorer view, expand the circle.h class, click the circle class element, and drag it into the diagram editor.
  2. Expand the sphere.h class, click the sphere class element, and drag it into the diagram editor.
You have now visualized the circle and shape classes. Your diagram should look similar to the following figure:

The base shapes classes and the circle and sphere classes are visualized using the C++  visualizer.

The diagram represents the hierarchy of the Shapes project. The diagram shows the visualized classes, their operations, and the inheritance and usage relationships that exist between classes. This diagram illustrates the 2-dimensional and 3-dimensional class hierarchies and their relationship to the base shape class.

In the next exercise, you use this diagram to visually extend the Shapes project.

To continue, proceed to Exercise 2: Extending the circle and sphere classes.