Inheritance: 'A' is an inaccessible base of 'B'

'boost::enable_shared_from_this<net::Session>' is an inaccessible base of 'net::Session'
         BOOST_ASSERT( p.get() == this );

在使用enabel_shared_from_this是遇到报错

研究了一下是继承的时候没有采用public继承的原因

https://blog.csdn.net/crazyhacking/article/details/8013458

这个文章指明private/protected继承时A的指针不能指向B

不过感觉没理解,如果看这个文章c++三种继承方式public,protect,private

可能是protected继承使得this指针对子类不可访问。接下来进行测试

 

额,很奇怪,测试结果好像没啥问题,测试了几种可能性:

在protected继承下

1.Base使用了this的函数不能被Derived调用 X

2.Base的this和Derived*不能做==操作 X

 

posted @ 2018-12-07 10:40  _离水的鱼  阅读(1488)  评论(0)    收藏  举报