What does “a class instantiates another” mean?

好久不见. 提交于 2019-12-11 17:06:47

问题


From Design Pattern by GoF:

Another useful thing to show is which classes instantiate which others. We use a dashed arrowheaded line to indicate this, since OMT doesn't support it. We call this the "creates" relationship. The arrow points to the class that's instantiated. In Figure B.lc, CreationTool creates LineShape objects.

What does "a class instantiates another" mean here?

Thanks.


回答1:


Another way to phrase it would be "a class creates an instance of another", which makes it a little more obvious.

It just means that Class A creates an instance of Class B inside of it (or "Class A instantiates Class B").

For example, you might have a Person class, which creates an instance of a Hand class, which it then uses.



来源:https://stackoverflow.com/questions/46474621/what-does-a-class-instantiates-another-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!