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