How to create a class that “extends” two existing concrete classes

后端 未结 8 2052
悲哀的现实
悲哀的现实 2020-12-19 20:36

I very well know that it can be done with the help of interfaces and i have done it many times. But this time my situation is quite difference. I have class A ,

8条回答
  •  悲&欢浪女
    2020-12-19 21:37

    A common oop principle is "choose composition over inheritance", since you can't extend 2 classes I would suggest having one of or both of those classes as members of Class C, that is of course if that works for what you are trying to do.

提交回复
热议问题