简体   繁体   中英

Adding constructors and destructors in a UML class diagram for C++ classes

在为C++代码编写UML类图时,是否需要包含相关类的构造函数和析构函数?

In many cases, adding constructors/destructors to a C++ class diagram would just be textual boilerplate noise and not really meaningful. Only if you want your diagram to be a complete documentation of your C++ classes, you may want to add constructors.

Contrary to what @Marco is saying below, this is not a matter of the underlying business logic, but a purely ergonomic issue of avoiding cluttering and noise in (typically complex) diagrams.

The constructor can be added if it's part of the business logic, you just don't add a return type.
Would be under the functions/methods section:
+ClassName()
I would not add destructors. Again, depends on whether your business logic needs it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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