简体   繁体   中英

Multiple Inheritance, copy constructor, and base class initialization?

How do I write a copy constructor with Multiple Inheritance?

B1 and B2 is inherited by D there is no diamond in inheritance chain. I need to write a copy constructor in D such that it calls copy constructors of B1 and B2

I want to avoid writing a clone() here

What's wrong with the classical approach:

D(const D& other) : B1(other), B2(other)
{
}

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM