| |

VerySource

 Forgot password?
 Register
Search
View: 770|Reply: 4

Multiple inheritance is generally discouraged, but why is it used a lot in COM?

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-22 17:40:01
| Show all posts |Read mode
Why not use object composition?

doubt
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-2-2 09:00:01
| Show all posts
Multiple inheritance that is not advocated generally refers to multiple inheritance implementation classes, and multiple inheritance of abstract classes (interfaces) is good. Object composition can replace inheritance, but it increases the amount of code, and there is nothing if inheritance does not cause any problems. Advantage
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-26 14:45:01
| Show all posts
People who don't use C ++ don't advocate using multiple inheritance!
Reply

Use magic Report

0

Threads

12

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-2 01:45:02
| Show all posts
I think this may be a problem of understanding: generally we say multiple inheritance, often referring to the realization of inheritance, this multiple inheritance is not advocated.
The multiple inheritance used in COM actually refers to interface inheritance, that is: functional inheritance
We often say that targeting an interface rather than implementing programming is reflected here. By inheriting the interface, the data and methods are separated, and at the same time,
The same calling method of the same type of class is reached (that is, the subclass can be called through the parent class)

In fact, this method is the same as the interface in Java, except that C ++ (or COM) is implemented by abstracting the parent class.
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-6 14:15:01
| Show all posts
I do n’t encourage the use of multiple inheritance. I suggest that the host can see the source code of wtl, maybe it will be very inspiring.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list