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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM