Design pattern to use instead of multiple inheritance

后端 未结 8 2527
离开以前
离开以前 2020-12-09 03:16

Coming from a C++ background, Im used to multiple inheritance. I like the feeling of a shotgun squarely aimed at my foot. Nowadays, I work more in C# and Java, where you can

8条回答
  •  轮回少年
    2020-12-09 03:47

    Your gut is correct in this case. The Adapter pattern is what you're looking for.

    DoFactory has good .NET examples (that should be pretty close to their Java counterparts as well):

    Adapter Design Pattern in C# and VB.NET

提交回复
热议问题