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
Best Answer
You have to do this:
The default inheritance type of a
class
in C++ isprivate
, so anypublic
andprotected
members from the base class are limited toprivate
.struct
inheritance on the other hand ispublic
by default.