Suppose I have a base and a derived class:
class Base { public: virtual void Do(); } class Derived:Base { public: virtual void Do(); } int main() { Derived sth; sth.Do();
apparently, I want to access the :: Do through Derived database. I get a compilation error as a โBase class inaccessibleโ, however, when I declare Derive as
class Derived: public Base
It works fine.
I read the default access for public inheritance, then why do I need to explicitly declare public inheritance here?
c ++ inheritance
paul simmons Sep 28 '10 at 9:33 2010-09-28 09:33
source share