简体   繁体   English

创建C ++类图

[英]Creating a C++ Class Diagram

In Visual Studio .NET projects you can add a "Class Diagram" to the project which renders a visual representation of all namespaces, classes, methods, and properties. 在Visual Studio .NET项目中,您可以向项目添加“类图”,从而呈现所有名称空间,类,方法和属性的可视化表示。 Is there any way to do this for Win32 (not .NET) C++ projects? 有没有办法为Win32(而不是.NET)C ++项目做到这一点? Either through Visual Studio itself or with a 3rd party tool? 通过Visual Studio本身或第三方工具?

Most UML tools should be able to do that. 大多数UML工具应该能够做到这一点。 I know that Sparx Systems Enterprise Architect does. 我知道Sparx Systems Enterprise Architect的确如此。

If you have a Visual Studio 2008 solution composed of multiple C++ projects, you can only generate one class diagram per project. 如果您有一个由多个C ++项目组成的Visual Studio 2008解决方案,则每个项目只能生成一个类图。

For example, if you have one application project linking to 10 library projects, you'll have to generate 11 separate class diagrams. 例如,如果您有一个链接到10个库项目的应用程序项目,则必须生成11个单独的类图。

There are two ways to work around this, neither of which is pleasant: 有两种方法可以解决这个问题,这两种方法都不令人满意:

  1. Cram all the source into a single project. 将所有源代码塞入单个项目中。
  2. Create a class diagram for one project (the application, perhaps) and then drag files from all the other projects into the class diagram. 为一个项目(可能是应用程序)创建一个类图,然后将所有其他项目中的文件拖到类图中。

A more thorough exploration of the capabilities of the Visual Studio class designer is given in Visual C++ Class Designer . Visual C ++类设计器中提供了对Visual Studio类设计器功能的更全面的探索。

Given the poor support for C++ class diagrams in Visual Studio, you're probably better off going with a commercial tool if you want anything more than a simple list of what classes you have. 鉴于Visual Studio中对C ++类图的支持不佳,如果你想要的不仅仅是一个简单的类列表,你最好还是使用商业工具。 WinTranslator from Excel Software might be worth looking at, and someone I work with uses Source Insight . Excel Software的WinTranslator可能值得一看,与我合作的人使用Source Insight

我有VS2008 SP1 Professional,类图适用于C ++ WIN32和Makefile项目。

如果您使用的是Visual Studio,则直到Visual Studio 2008才能正确实现C ++的类图。

Class designer is not meant for C++, even in VS 2008. You will be better off with some more specialized tool. 即使在VS 2008中,类设计器也不适用于C ++。使用更专业的工具会更好。 It works for simple projects which don't heavily use templates. 它适用于不大量使用模板的简单项目。 Also, get modeling power toys from codeplex. 此外,从codeplex建模动力玩具。

Try doing partial specializations and watch how it crams everything into a single shape. 尝试进行部分特化,并观察它如何将所有东西变成单一形状。

一种便宜的方法是使用Doxygen记录您的源代码,并让此工具为您创建类图。

If your project is a c++ based project then you have to drawn class diagram of c++ first,If your project contain 'n' number of sub-projects then you have to drawn 'n+1' number of class diagram. 如果您的项目是基于c ++的项目,那么您必须先绘制c ++的类图,如果您的项目包含'n'个子项目,那么您必须绘制'n + 1'个类图。

Basically a class diagram contains 基本上类图包含

  1. class variables. 类变量。
  2. class functions. 类功能。
  3. Relation between classes. 类之间的关系。

You should place all the properties which are required for a class inside a class diagram. 您应该将类​​所需的所有属性放在类图中。 It looks like a table (graphical structure) having 3 rows type box. 它看起来像一个具有3行类型框的表(图形结构)。

Row 1. class name(If it is an Object diagram it should and must under lined). 行1.类名(如果它是一个对象图,它应该并且必须在下面)。
Row 2. Variable list(One variable in one line). 第2行。变量列表(一行中的一个变量)。
Row 3. Function list(One function in one line) 第3行。功能列表(一行中有一个功能)

You have to make the Relation between one class to another class. 你必须使一个类与另一个类之间的关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM