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