Class Designer for C++ in Visual Studio 2008

Let me spoil it for you: it’s not an actually class designer, because it’s only one way. It should have been called Class Viewer, but probably it get’s more publicity if it’s called designer.

Let me explain how to us it. Of course, you need to have some source code for which you want to see the class diagrams. Just to exemplify, let’s consider the following code:

To be able to view a diagram for the classes, structs, and other entities, you must add a Class Diagram file (has the extension .cd). You can either do that from the menu (Project > Add new Item), Solution Explorer or simply by pressing Ctrl + Shift + A. The new file will be opened and you’ll have to drag and drop items from the Class View or the Solution Explorer.

Class View in Visual Studio 2008

When you drop classes that are part of hierarchies the arrows indicating the relationships are automatically shown.

Example Class Diagram for C++ classes

If you double click on a member (function, field, etc.) you will be directed in the code where it is defined. If you right-click on a class, you’ll get a menu with commands, but, as I was saying earlier, there is no possibility to add new elements from the designer.

Context menu in class designer

Class details are shown in an additional pane, and of course, they are also read-only.

Class details for the components of the class diagram

You can also use the Class Designer toolbar for sorting elements, changing the layout or zooming.

I can only hope this is only a first step and that the next version of Visual Studio will feature a real designer for C++ too.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.