• Private Inheritance for C++


      C++ has a second means of implementing the has-a relationship: private inheritance.With private inheritance, public and protected members of the base class become private members of the derived class.This means the methods of the base class do not become part of the public interface of the derived object.They can be used, however, inside the member functions of the derived class.
    Let’s look at the interface topic more closely.With public inheritance, the public methods of the base class become public methods of the derived class. In short, the derived class inherits the base-class interface.This is part of the is-a relationship.With private inheritance, the public methods of the base class become private methods of the derived class. In short, the derived class does not inherit the base-class interface.As you saw with contained objects, this lack of inheritance is part of the has-a relationship.  

                                                                from 《c++ primer plus》 

    当你的才华还撑不起你的野心时,那你就应该静下心来学习。
  • 相关阅读:
    OC之class与metaclass
    call vs apply
    ABI
    WEB服务器的四种类型
    情绪控制
    位置无关代码
    Finding Leaks Using Instruments
    Mac之TwoLevel Namespace
    Apache的几个特性
    Mac之debuging symbol
  • 原文地址:https://www.cnblogs.com/aceg/p/6942637.html
Copyright © 2020-2023  润新知