Inheritance models an IS A relationship (aka Generalization / Specialization realtionship) among the classes

== > Public Inheritance relationship is IS A relationship

( 부모 인터페이스를 자식 인터페이스의 일부로 포함시킴 )

screenshot

자식이 부모에 dependent 하다. (data flow 가 아닌 dependency 의존관계 표현)

A class can be a superclass as well as a subclass at the same time and the IS A relationship is transtive

Subclasses inherit all sttributes and operations from its superclass and its ancestors
—————

Subclasses can be redefine inherited operations (Overriding)

–>  Operations must have the same Signatures

–>  Subclasses can alter or override information inherited from parent classes



Anything that is true of an object of Person type is also true of an object of Student type, but Not vice - versa   (부모에 성립되는 것들은 자식에서도 성립된다.)

Anything a superclass can do, a subclass can do as well


Subtyping uses inheritance as a mechanism for Interface sharing
—————-

  • enforces the IS A relationship
  • also called Interface inheritance

Subclassing uses inheritance as a mechanism for Implementation sharing

  • enforces implemented in terms of relationship
  • also called class inheritance or implementation inheritance
    -> private Inheritance ( only C++ )

Pure virtual function

  • to have derived class inherit a function interface only

Virtual function

  • to have derived classes inherit a function interface as well as a default implementation
    (overriding O == abstract method)

Nonvirtual function

  • to have derived classes inherit a function interfaces as well as a mandatory implementation
    (overriding X == final method)