C++ inheritance - inaccessible base?

http://stackoverflow.com/questions/4847100/c-inheritance-inaccessible-base

I seem to be unable to use a base class as a function parameter, have I messed up my inheritance?

 

I have the following in my main:

 

int some_ftn(Foo *f) { /* some code */ };
Bar b;
some_ftn(&b);

 

And the class Bar inheriting from Foo in such a way:

class Bar : Foo
{
public:
    Bar();
    //snip

private:
    //snip
};

Should this not work? I don't seem to be able to make that call in my main function

 

 

 think you might have to do this:

classBar:publicFoo{// ...}

The default inheritance type of a class in C++ is private, so any public and protected members from the base class are limited to privatestructs on the other hand are public by default.

 

 

posted on 2012-10-29 20:51  Orz..  阅读(316)  评论(0)    收藏  举报

导航