What is delegation? When would I want to use it?

前端 未结 2 1218
走了就别回头了
走了就别回头了 2021-01-18 03:24

In OOP, a term delegation is mentioned. How is this modelled in a class? I searched on yahoo etc but got links to delegates.

2条回答
  •  执笔经年
    2021-01-18 04:08

    Delegation is like inheritance except instead of class2 having copied functions and variables from class1 class2 just gets class1 to do that stuff for it and class2 focuses on doing and having the extra functions and variables you give it. One obvious advantage of this is it saves space on your computer.

提交回复
热议问题