My understand of Friend and Protected 怼烎@ 2021-12-15 09:03 148阅读 0赞 **Friend** My understanding of Friend is equivalent to “project scope”. [![PublicAndFriend1][]][PublicAndFriend1 1] **Protected** The official definiton is that elements are accessible only from within their own class *or from a derived class*. In OO concept, The relation between a derived class to parent class is “is-a”. For example, international student is a student. My understanding of protected is that elements are accessible to “Same thing” only. [![Protected][]][Protected 1] 转载于:https://www.cnblogs.com/yangbin990/archive/2009/05/05/1450191.html [PublicAndFriend1]: /images/20211214/3b511beaf3b64352bc2b029023b5c3a0.png [PublicAndFriend1 1]: http://images.cnblogs.com/cnblogs_com/yangbin990/WindowsLiveWriter/UnderstandpublicprivateprotectedFriendPr_B4C3/PublicAndFriend1_2.jpg [Protected]: /images/20211214/1a2cb054e221499cb7df20eebabfeb5c.png [Protected 1]: http://images.cnblogs.com/cnblogs_com/yangbin990/WindowsLiveWriter/UnderstandpublicprivateprotectedFriendPr_B4C3/Protected_2.jpg
还没有评论,来说两句吧...