简体   繁体   中英

C++ Inheritance Hierarchy

Say I have a public class Parent and two derived children classes called son and daughter. I then have a single derived class called toys underneath the daughter class.

If I call:

class toys : public daughter {

}

does this class inherit all the protected and public variables/functions within the daughter class AND the parent class? When creating a hierarchy and using the " derived class : accessor-type base class " syntax, do you add another colon to access all the variables/functions another class up, or is it a chain of inheritance from the top-down?

"does this class inherit all the protected and public variables/functions within the daughter class AND the parent class"

Yes toys class will inherit everything from both daughter and parent. But how members of the base class appear in the derived class depends on what member access specifier is used.

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