The document discusses key concepts in object-oriented programming (OOP) including objects, classes, encapsulation, inheritance, polymorphism, and message passing. It provides examples of a simple class named "item" that includes variables and methods. It also discusses how objects are composed of data and functions, and how classes are used to organize data and functions through principles like private/public access and data abstraction.
5. Classes and Objects A class is a definition of an object. It's a type just like int. A class resembles a struct with just one difference : All struct members are public by default. All classes members are private by default.
6. Remember : A class is a type object of this class is just a variable
8. A Simple Class class item { int number; // variables declaration float cost; // private by default Public: void getdata(int a, float b); // functions declaration void putdata(void); // using prototype }; // ends with semicolon
9. What is Object Oriented Programming? An object is like a black box. The internal details are hidden. Identifying objects and assigning responsibilities to these objects. Objects communicate to other objects by sending messages . Messages are received by the methods of an object
10. What is an object? Tangible Things as a car, printer, ... Roles as employee, boss, ... Incidents as flight, overflow, ... Interactions as contract, sale, ... Specifications as colour, shape, …
11. So, what are objects? an object represents an individual, identifiable item, unit, or entity, either real or abstract, with a well-defined role in the problem domain. Or An "object" is anything to which a concept applies. Etc.
12. Why do we care about objects? Modularity - large software projects can be split up in smaller pieces. Reuseability - Programs can be assembled from pre-written software components. Extensibility - New software components can be written or developed from existing ones.
13. Example: The Person class #include<string> #include<iostream> class Person{ char name[20]; int yearOfBirth; public: void displayDetails() { cout << name << " born in " << yearOfBirth << endl; } //... }; private data public processes
14. The two parts of an object Object = Data + Methods or to say the same differently: An object has the responsibility to know and the responsibility to do. = +
15. Data Functions Object A Data Functions Object B Data Functions Object C Communication Organization of data and functions in OOP Private Public
16. Class User-defined data type Objects are variables of the type class Any number of objects can be created from one class Collection of objects of similar user-defined data types fruit mango; Will create an object mango belonging to the class fruit .
17. Data Encapsulation The wrapping up of data and functions into a single unit ( called class) is known as encapsulation . Class is not accessible by outside world Only its own functions can access it The insulation of the data from direct access by the program is called data hiding or information hiding .
18. Data Abstraction Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction They are defined as a list of abstract attribute such as size, weight, cost and functions to operate on these attributes.
19. Trivia (something of small importance) Attributes also called data members Because the hold information. Functions that operate on these data are called methods or member functions .
20. Inheritance Inheritance is the process by which objects of one class acquire the properties of objects of another class. It support the concept of hierarchical classification . Bird robin is a part of the class flying bird which is again a part of the class bird .
24. Dynamic Binding Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding also know as late binding means the code associated with a given procedure call is not known until the time of the call at run-time.
25. Message Passing An object oriented program consists of a set of objects that communicate with each other. Employee.salary (name); Object message information