C++ inheritance - inaccessible base?

后端 未结 2 1095
梦谈多话
梦谈多话 2020-11-28 05:15

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          


        
2条回答
  •  有刺的猬
    2020-11-28 06:10

    You have to do this:

    class Bar : public Foo
    {
        // ...
    }
    

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

提交回复
热议问题