Variable inaccessible despite class inheritance?

This question already has an answer here:

  • Difference between private, public, and protected inheritance 15 answers

  • private variables are not accessible by derived classes. If you want to have access to it, you'll need to declare it as protected .

    Also, your Truck class should declare a virutal destructor if you plan to use it as a polymorphic base class.

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

    上一篇: 继承如何实际工作?

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