c++ inheritance syntax

Possible Duplicate:
What are access specifiers? Should I inherit with private, protected or public?
Difference between private, public and protected inheritance in C++

To all you cpp experts, In c++ inheritance,

class B : public A {
};

I am just curious why is the keyword public needed here? Does it mean something?


It means public members in A are inherited by B and are also public from B .

The alternatives are:

  • protected - public members from A are made protected in B , others are kept the same.

  • private - all members from A are made private in B .

  • The rules don't apply to methods that are hidden or overriden.

    链接地址: http://www.djcxy.com/p/78550.html

    上一篇: 尽管类继承,变量不可访问?

    下一篇: c ++继承语法