Variable inaccessible despite class inheritance?
This question already has an answer here:
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.
上一篇: 继承如何实际工作?
下一篇: 尽管类继承,变量不可访问?