软件重用:
组合:对象拼出新的对象。 C++:组合出来的也是类
继承:类得到新的类
reusing the interface
- inheritance is to take the existing class,clone it,and then make additions and modifications to the clone.
inheritance
- language implementation technique
- also an important component of the OO design methodology
- allows sharing of design for
- member data
- member functions
- interfaces(对外公开的部分)
member functions可以是public、private。public的 member functions 和 member data 是interfaces。
- key technology in C++
- the ability to define the behavior or implementation of one class a superset of another class
- class relationship:
- Employee(Base class,Super,Parent)<-----Manager(Derived Class,Sub,Child)
parent类private东西在子类存在,但是Child类不能直接修改,可以使用Parent类的开放接口使用。
protected: Child类内可以使用,但是外界无法访问。
parent类:所有的数据都是private, 开放的东西放到 public 中, protected只有Child类内可以使用。