A use for multiple inheritance?

后端 未结 12 1884
暖寄归人
暖寄归人 2020-11-29 07:29

Can anyone think of any situation to use multiple inheritance? Every case I can think of can be solved by the method operator

AnotherClass() { return this-&         


        
12条回答
  •  温柔的废话
    2020-11-29 07:52

    One case I worked on recently involved network enabled label printers. We need to print labels, so we have a class LabelPrinter. This class has virtual calls for printing several different labels. I also have a generic class for TCP/IP connected things, which can connect, send and receive. So, when I needed to implement a printer, it inherited from both the LabelPrinter class and the TcpIpConnector class.

提交回复
热议问题