在OOP中,什么是转发,它与委派有什么不同? [英] In OOP, what is forwarding and how is it different from delegation?

查看:123
本文介绍了在OOP中,什么是转发,它与委派有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释转发和委派之间的区别吗?它们看起来很相似,但是我无法找到正确的转发定义,所以我不确定我是否真正理解。

Would someone please explain the difference between forwarding and delegation? They seem similar, but I haven't been able to find a good definition of forwarding, so I'm not sure I really understand.

推荐答案

首先定义两个术语:


  • 发件人将消息/任务发送到另一个对象(接收者)

  • 接收者接收一个对象的对象发件人的邮件/任务

  • sender : the object that sends a message/task to another object(the receiver)
  • receiver: the object that receives a message/task from the sender

转发委托是在转发 中,接收者在自己的上下文中起作用而在委托 <$ c中$ c>接收者代表发送者行事

这里是这个博客文章

授权和转发都非常相似。一个可能有助于区分他们的比喻是考虑收到一封电子邮件,要求您向有价值的慈善机构捐款。

Delegation and forwarding are both very similar. One metaphor that might help distinguish them is to think of receiving an email asking you to donate some money to a worthy charity.


  • 如果您转发给朋友的电子邮件,然后朋友捐赠了钱,朋友正在捐赠自己的钱并获得了自己的税收收据。

  • 如果您委托回复您的会计师,则会计师将您的钱捐赠给慈善机构,您会收到税收收据。

  • If you forward the email to a friend, and the friend donates money, the friend is donating their own money and getting their own tax receipt.
  • If you delegate responding to your accountant, the accountant donates your money to the charity and you receive the tax receipt.

这篇关于在OOP中,什么是转发,它与委派有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆