Object Oriented Program

1,503 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,503
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
89
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Object Oriented Program

  1. 1. Concept of C++
  2. 2. Paradigms – Paradigms means organizing principle of a program. It is an approach to a program.Types of programming:- Procedural programming Modular Programming Object Oriented programming
  3. 3. Procedural programming lays more emphasis on procedure than data. Problems raised while extending the software or maintaining software by using procedural programming:- It is susceptible to design changes. It leads to increased time and cost overheads during design changes.
  4. 4. Module- A set of related procedure with data they manipulate is called a module.In Modular Programming, since many modules ( or functions) access the same data, the way the data is stored becomes critical. The arrangement of the data can’t be changed without modifying all the functions that access it.
  5. 5. The Object Oriented approach views a problem in terms of objects involved rather than procedure for doing it.
  6. 6. OBJECT ORIENTED PROCEDURAL PLANNING PROGRAMMING Here emphasis is an  Here emphasis is on object. doing functions.  It follows Top-down It follows Bottom-Up approach in program approach in program design. design.  Here presence of Global variables increase Its data hiding feature changes of accidental prevents accidental change in data. change in data.  Features like Its features like data encapsulation, data encapsulation, hiding, polymorphism polymorphism, inheritance are absent. are present.
  7. 7. Objects are key to understanding object-oriented technology. An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages).Methods operate on an objects internal state and serve as the primary mechanism for object-to- object communication.
  8. 8. A class is a group of objects that share common properties and relationships.
  9. 9. class class-name{ private: [variable declaration;] [function declaration;] protected : [variable declaration;] [function declaration;] public : [variable declaration;] [function declaration;] }
  10. 10.  Data Abstraction Data Encapsulation  Modularity  Inheritance  Polymorphism
  11. 11.  Data abstraction refers to the act of representing essential features without including the background details or explanations. Data abstraction is the concept of simplifying a real world concept into essentials elements
  12. 12. The wrapping up of data and operations/functions (that operate on the data) into a single unit (called class) is known as encapsulation. DATA OBJECT MEMBER OBJECT FUNCTIONS DATA DATA MEMBER MEMBER FUNCTIONS OBJECT FUNCTIONS
  13. 13. Data modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.
  14. 14. It is the capability of one class of things toinherit capabilities or properties from other class. CLASS BASE DERIVED CLASS CLASS
  15. 15. Single Inheritance Multiple InheritanceHierarchical InheritanceMultilevel Inheritance Hybrid Inheritance
  16. 16. In this type of inheritance a sub class inherits only from one base class. x BASE CLASS Y DERIVED CLASS
  17. 17. class Sub : public Super //public derivation{ : //members of Sub //(the derived class)};Class Sub : private Super //private derivation{ : //members of Sub};
  18. 18. class Sub : protected Super //protected //derivation{ : //members of Sub};class Sub : Super //private derivation by default{ :};
  19. 19. In this type of heritance a sub class inherits from multiple base classes. BASE CLASSES x Y Z DERIVED CLASS
  20. 20. Class Sub : public SuperA,private SuperB{ : //members};
  21. 21. In this type of inheritance many sub classes inherit from a single base class. Z BASE CLASS W X Y DERIVED CLASSES DERIVED CLASSES
  22. 22. The transitive nature of inheritance is reflected by this form of inheritance . In this form a class that itself inherits from another class. X BASE CLASS OF Y Y DERIVED CLASS OF X BASE CLASS OF Z Z DERIVED CLASS OF Y
  23. 23. Hybrid inheritance combines two or more forms of inheritance. EXAMPLE X Y Z A B C
  24. 24. Polymorphism is the visibility for a message or data to be processed in more than one form .It is a property by which the same message can be sent to objects of several different classes and each object can respond in a different way depending on its class .
  25. 25. void prnsqr (into i){ cout<<“Integer”<<i<<“ „s square is”<<i*i<<endl;}void prnsqr(char c);{ cout<<c<<“is character”; cout<<“Thus No square for it”<<endl;}void prnsqr(float f){ cout<<“Double float”<<f<<“ „s square is”<<f*f; cout<<endl;}void prnsqr(double d){ cout <<“Double float”<<d<<“ „s square is”<<d*d<<endl;}
  26. 26. Re – use of codeEase of comprehensionEase of fabrication and maintenanceEasy redesign and extension
  27. 27.  With OOP, classes tend be overly generalized. The relations among classes become artificial at times. The OOP programs design is tricky. Also one needs to do proper planning and proper design for OOP programming. To program with OOP, programmer need proper skills such as design skills, programming skills, etc.

×