简体   繁体   English

class 图中的初始化程序列表 C++

[英]Initializer list C++ in class diagram

I just study class diagram for a few days ago and now I meet a problem where the constructor has its initializer list, is there any way to show the initializer list in class diagram, with example would be good, thank you in advance.几天前我刚刚研究了 class 图,现在我遇到了构造函数有其初始化列表的问题,有没有办法在 class 图中显示初始化列表,有例子就好了,提前谢谢你。

A C++ inializer list is just the type of a parameter of a constructor, like any other. C++ 初始化器列表只是构造函数的参数类型,就像其他任何参数一样。

In the class diagram, you'd therefore show the corresponding constructor (preceded with «create») as an operation with a parameter of this type.因此,在 class 图中,您将显示相应的构造函数(前面带有 «create»)作为具有此类型参数的操作。

If you want to highlight it, you could add in the diagram the initalizer_list as a separate UML template class and draw a dependency of the class or its constructor to this template.如果要突出显示它,可以在图中将initalizer_list添加为单独的UML 模板 class并将 class 或其构造函数的依赖关系绘制到此模板。 But this is not required, and could quickly lead to undreadable diagrams if many classes use this mechanism.但这不是必需的,如果许多类使用这种机制,很快就会导致图表不可读。

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

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