聚合、遏制和聚合的解释com 中的代表团
你能解释一下聚合、包含和聚合之间的区别吗?代表团
can u explain me what is the difference between aggregation, containment & delegation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
你能解释一下聚合、包含和聚合之间的区别吗?代表团
can u explain me what is the difference between aggregation, containment & delegation
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
由于您已使用 COM 对其进行了标记,因此我假设您是在询问 COM 如何使用这些术语 - 在 COM 术语中,它们的含义比一般使用时更具体。
方便的是,MSDN 有定义这些的页面 - 我将给出一个简短的总结:
包含/委托 - 当一个外部对象拥有(包含)并使用(委托)一个内部对象时。这两个对象维护不同的标识和独立的接口集。
聚合 - 当两个或多个 COM 对象本质上汇集其接口并表现得就像单个 COM 对象一样。然后,客户端代码处理看似单个对象,但实际上是其他对象的“聚合”。
当您希望一个对象从另一个对象“继承”一组接口时,通常使用聚合。然而,实现起来有些复杂:COM 要求您必须能够从对象上的任何接口对任何其他接口进行 QI 操作,因此涉及的各个对象必须合作以确保您可以从其中一个对象上的任何接口进行 QI 操作对于另一个对象上的任何接口,一个对象可以跨两个对象进行引用计数。
Since you've tagged this with COM, I'll assume you're asking how COM uses these terms - in COM terminology they mean something somewhat more specific than when used in general.
Conveniently, MSDN has pages that define these - I'll give a brief summary:
Containment/Delegation - when one outer object owns (contains) and makes use of (delegates to) an inner object. The two objects maintain distinct identities and separate sets of interfaces.
Aggregation - when two or more COM objects essentially pool their interfaces and behave as though they are a single COM object. The client code is then dealing with what appears to be a single object, but is in fact an 'aggregate' of other objects.
Aggregation is usually used when you want one object to 'inherit' a set of interfaces from another object. It's somewhat complex to implement, however: COM requires that from any interface on an object you must be able to QI to any other interface, so the various objects involved have to cooperate to ensure that you can QI from any interface on one of the objects to any interface on the other, an have ref counting work across both objects.
包含描述了一个类的想法,该类具有作为另一类/类型的对象的数据成员。
委派表达了一个类使用另一个类来完成任务或目标的想法。
委派通常是通过遏制来完成的
Containment describes the idea of one class, having a data member that is an object of another class/type.
Delegation expresses the idea that one class uses another class to accomplish a task or goal.
Delegation is usually accomplished by containment
聚合 和 Containment 是对象组合的通用概念(com 或任何其他技术之上的概念)。 对象组合链接,在 com 中也有一个关于聚合的单独部分。
同样,您可以阅读有关委托的内容。
Aggregation and Containment are generic concepts (concepts above com or any other technology) of Object Composition. The Object Composition link, has a separate section on Aggregation in com also.
Similarly, you can read about delegation.