Programming in c++ Object-Oriented Software Development Dale/eems/Headington
1 Object-Oriented Software Development
Programming in C++ Chapter 14 Topics o Structured Programming vS Object-Oriented Programming o Using Inheritance to Create a New C++ class Type o Using Composition(Containment) to Create a New C++ class Type x Static vS. Dynamic Binding of Operations to Objects Virtual Member Functions Object-Oriented Design Implementing the Design
2 Chapter 14 Topics ❖Structured Programming vs. Object-Oriented Programming ❖Using Inheritance to Create a New C++ class Type ❖Using Composition (Containment) to Create a New C++ class Type ❖Static vs. Dynamic Binding of Operations to Objects ❖Virtual Member Functions ❖Object-Oriented Design ❖Implementing the Design
Programming in C++ Structured Programming vs Object-Oriented programming Structured(procedural)programming: the construction of programs that are collections of interacting functions or procedures Object-oriented programming(ooP) the use of abstraction, inheritance, and dynamic binding to construct programs that are collections of interacting objects
3 Structured Programming vs. Object-Oriented programming ❖Structured(procedural)programming:the construction of programs that are collections of interacting functions or procedures. ❖Object-oriented programming(OOP):the use of abstraction, inheritance, and dynamic binding to construct programs that are collections of interacting objects
Programming in C++ Two Programming Paradigms Structural ( Procedural) Obiect-Oriented PROGRAM PROGRAM(OOP) FUNCTION OBJECT Operations FUNCTION Data OBJECT OBJECT Operations FUNCTION Operations Data Data
4 Two Programming Paradigms Structural (Procedural) Object-Oriented PROGRAM PROGRAM(OOP) FUNCTION FUNCTION FUNCTION OBJECT Operations Data OBJECT Operations Data OBJECT Operations Data
Programming in C++ Object-Oriented Programming Language Features 1. Data abstraction 2. Inheritance of properties 3. Dynamic binding of operations to objects
5 Object-Oriented Programming Language Features 1. Data abstraction 2. Inheritance of properties 3. Dynamic binding of operations to objects
Programming in C++ Obiects OOP Terms C++ Equivalents Object Class object or class instance Instance variable Private data member Method Public member function Message passing Function call( to a public member function
6 OOP Terms C++ Equivalents Object Class object or class instance Instance variable Private data member Method Public member function Message passing Function call ( to a public member function ) Objects
Programming in C++ What is an object? OBJECT set of methods Operations (public member functions) Data internal state (values of private data members)
7 What is an object? OBJECT Operations Data set of methods (public member functions) internal state (values of private data members)
Programming in C++ Relationship Between Two Classes In C++, we define the properties and behavior of objects by using the class mechanism The three most common relationships between two classes are as follows 1. Two classes are independent of each other and have nothing in common 2. Two classes are related by inheritance 3. Two classes are related by composition
8 Relationship Between Two Classes ❖In C++, we define the properties and behavior of objects by using the class mechanism. ❖The three most common relationships between two classes are as follows: 1. Two classes are independent of each other and have nothing in common. 2. Two classes are related by inheritance. 3. Two classes are related by composition
Programming in C++ Inheritance Hierarchy Among Vehicles vehicle wheeled vehicle boat car bicycle two-door four-door Every car is a wheeled vehicle 9
9 Inheritance Hierarchy Among Vehicles vehicle wheeled vehicle boat car bicycle two-door four-door Every car is a wheeled vehicle
Programming in C++ Inheritance is a mechanism by which one class acquires (inherits) the properties(both data and operations) of another class the class being inherited from is the Base class (Superclass) the class that inherits is the Derived class (Subclass) .g the derived class is then specialized by adding properties specific to it 10
10 Inheritance ❖ is a mechanism by which one class acquires (inherits) the properties (both data and operations) of another class ❖ the class being inherited from is the Base Class (Superclass) ❖ the class that inherits is the Derived Class (Subclass) ❖ the derived class is then specialized by adding properties specific to it