The c ++ Programming Language Lecture 5 Object-Oriented Programming
The C++ Programming Language Lecture 5: Object-Oriented Programming
Basic Concepts
Basic Concepts
Object Based object Oriented u Object Based Programming Classes regarded as new data types Single layer in hierarchy Not convenient in"Entity-Relation" relationship s has is implemented of Object Oriented Programming Focus on the relationship between classes Hierarchical in structure Good at Entity-Relation" relationship Main features: inheritance and polymorphism
Object Based & Object Oriented ◼ Object Based Programming ◼ Classes regarded as new data types ◼ Single layer in hierarchy ◼ Not convenient in “Entity-Relation” relationship – “is-a” – “has-a” – “is implemented of” ◼ Object Oriented Programming ◼ Focus on the relationship between classes ◼ Hierarchical in structure ◼ Good at “Entity-Relation” relationship ◼ Main features: inheritance and polymorphism
Inheritance u Organize those related classes and share their common data and operations a Parent/child relationship Parent(Base) class: defined common public interfaces and private implements of all child classes Child (derived) class: could override what is inherited, or add new implementations to fit its speciality
Inheritance ◼ Organize those related classes, and share their common data and operations ◼ Parent/child relationship ◼ Parent (Base) class: defined common public interfaces and private implements of all child classes ◼ Child (Derived) class: could override what is inherited, or add new implementations, to fit its speciality
Inheritance Hierarchy bstract Base Class> Lib Materials Books Magazine Files Rental Books Audio Books E-Books a If the root do not represent a real object, and it is only for design need we could call it Abstract Base Class( conceptual)
Inheritance Hierarchy ◼ If the root do not represent a real object, and it is only for design need, we could call it Abstract Base Class (Conceptual) Lib Materials Books Magazines Files Rental Books Audio Books E-Books Abstract Base Class →