C ++inheritance – 无法访问的基础?
我似乎无法使用基类作为函数参数,我弄乱了我的inheritance?
我的主要内容如下:
int some_ftn(Foo *f) { /* some code */ }; Bar b; some_ftn(&b); 从Fooinheritance的类Bar是这样的:
 class Bar : Foo { public: Bar(); //snip private: //snip }; 
如果这不起作用? 我似乎无法在我的主要function中打这个电话
你必须这样做:
 class Bar : public Foo { // ... } 
  C ++中class的默认inheritancetypes是private ,所以来自基类的public和protected成员都被限制为private 。 另一方面, structinheritance是默认public的。 
 默认情况下,inheritance是私有的。 你必须明确地使用public : 
 class Bar : public Foo