INTRODUCTION TO OBJECT - ORIENTED PROGRAMMING PREPARED BY Patel Shruti J. BE- 4th sem
Programming Languages • Programming languages allow programmers to code software. • The three major families of languages are: – Machine languages – Assembly languages – High-Level languages
Machine Languages • Comprised of 1s and 0s • The “native” language of a computer • Difficult to program – one misplaced 1 or 0 will cause the program to fail. • Example of code: 1110100010101 111010101110 10111010110100 10100011110111
Assembly Languages • Assembly languages are a step towards easier programming. • Each assembly language is specific to a particular computer architecture. • Assembly language code needs to be translated to machine language before the computer processes it. • They are translated by an assembler into machine language. • Assembly language uses mnemonic to represent each low level machine instruction or opcode, also each architectural register,flag.
High-Level Languages • High-level languages represent a giant leap towards easier programming. • The syntax of HL languages is similar to English. • It is converted into machine level language by compiler. • Historically, we divide HL languages into two groups: – Procedure oriented programming – Object-Oriented programming (OOP)
Procedure oriented programming • Early high-level languages are typically called procedural languages. • Procedural languages are characterized by sequential sets of linear commands. The focus of such languages is on structure. • Examples include C, COBOL, Fortran, LISP, Perl, HTML, VBScript
Procedure oriented programming • Structure of POP :
Procedure oriented programming • Features :  Emphasis is on procedure of doing things.  Larger programs are divided into smaller programs called functions.  Data can move openly around the system from function to function.  Adding of data and function is difficult.  Top down approach in program design.
Object-Oriented Programming Definition of OOP: • Object oriented programming is a programming methodology that associates data structures with a set of operators which act upon it.
Object-Oriented Programming • Most object-oriented languages are high-level languages. • The focus of OOP languages is not on structure, but on modeling data. • Programmers code using “blueprints” of data models called classes. • Examples of OOP languages include C++, Visual Basic.NET and Java.
Object-Oriented Programming • Structure of OOP :
Object-Oriented Programming • Features :  Emphasis is on data.  Programs are divided into objects and classes.  Data is hidden and cannot be accessed by the external function.  New data and functions can be added when necessary.  Bottom up approach in program design.
Elements of OOP • Objects • Classes • Encapsulation • Data Abstraction • Inheritance • Polymorphism • Message Passing
Objects • OOP uses objects as its fundamental building blocks. • Objects are the basic run-time entities in an object- oriented system. • Every object is associated with data and functions which define meaningful operations on that object. • Object is a real world existing entity. • Object is an Instance of a particular class.
Objects DATAFUNCTIONS FUNCTIONS
Example: Student Object St_name St_id Branch Performance Result
Class • Class is a collection of similar objects. • Mango, Apple etc. are objects and their class is Fruit.
Encapsulation • Wrapping up of data and functions into a single unit (class) is called encapsulation. • Data is not accessible to outside world. • Only those functions which are which are wrapped in the class can access it.
Data Abstraction • A data abstraction is a simplified view of an object that includes only features one is interested in while hides away the unnecessary details. • Data abstraction becomes an abstract data type (ADT)or a user-defined type.
Inheritance • Inheritance is the mechanism to provides the power of reusability and extendibility. • Inheritance is the process by which one object can acquire the properties of another object. • Types :  Single  Multilevel  Multiple  Hybrid  Hierarchical
Inheritance
Polymorphism • Poly means many. Morphism means forms. • Polymorphism means that the same thing can exist in two forms. • Polymorphism is in short the ability to call different functions by just using one type of function call. • Ex : Bank can be used as - bank (river) - bank (finance)
Message Passing • Information or message of one object can be sent to other object. • Object communicate with one another by sending and receiving information much the same way as people communicate with each other. • A message for an object is a request for execution of a proedure and it will invoke a procedure in receiving object that generates the desired result.
Message Passing • Message passing involves specifying the name of the object, the name of the function and the information to be sent. • Ex- employee.salary(name); Object Message Information
Benefits of OOP • Through inheritance we can extend the use of existing classes. • Build secure program by data hiding. • Message passing techniques for communication between objects make is much simplier. • It is easy to partition the work in a project based on object.
Applications of OOP • Database management systems • Data security • Artificial intelligence and expert systems • Mobile computing • Real time systems • Simulation and modeling • Distributed computing
Introduction to oop with c++

Introduction to oop with c++

  • 1.
    INTRODUCTION TO OBJECT -ORIENTED PROGRAMMING PREPARED BY Patel Shruti J. BE- 4th sem
  • 2.
    Programming Languages • Programminglanguages allow programmers to code software. • The three major families of languages are: – Machine languages – Assembly languages – High-Level languages
  • 3.
    Machine Languages • Comprisedof 1s and 0s • The “native” language of a computer • Difficult to program – one misplaced 1 or 0 will cause the program to fail. • Example of code: 1110100010101 111010101110 10111010110100 10100011110111
  • 4.
    Assembly Languages • Assemblylanguages are a step towards easier programming. • Each assembly language is specific to a particular computer architecture. • Assembly language code needs to be translated to machine language before the computer processes it. • They are translated by an assembler into machine language. • Assembly language uses mnemonic to represent each low level machine instruction or opcode, also each architectural register,flag.
  • 5.
    High-Level Languages • High-levellanguages represent a giant leap towards easier programming. • The syntax of HL languages is similar to English. • It is converted into machine level language by compiler. • Historically, we divide HL languages into two groups: – Procedure oriented programming – Object-Oriented programming (OOP)
  • 6.
    Procedure oriented programming •Early high-level languages are typically called procedural languages. • Procedural languages are characterized by sequential sets of linear commands. The focus of such languages is on structure. • Examples include C, COBOL, Fortran, LISP, Perl, HTML, VBScript
  • 7.
  • 8.
    Procedure oriented programming •Features :  Emphasis is on procedure of doing things.  Larger programs are divided into smaller programs called functions.  Data can move openly around the system from function to function.  Adding of data and function is difficult.  Top down approach in program design.
  • 9.
    Object-Oriented Programming Definition ofOOP: • Object oriented programming is a programming methodology that associates data structures with a set of operators which act upon it.
  • 10.
    Object-Oriented Programming • Mostobject-oriented languages are high-level languages. • The focus of OOP languages is not on structure, but on modeling data. • Programmers code using “blueprints” of data models called classes. • Examples of OOP languages include C++, Visual Basic.NET and Java.
  • 11.
  • 12.
    Object-Oriented Programming • Features:  Emphasis is on data.  Programs are divided into objects and classes.  Data is hidden and cannot be accessed by the external function.  New data and functions can be added when necessary.  Bottom up approach in program design.
  • 13.
    Elements of OOP •Objects • Classes • Encapsulation • Data Abstraction • Inheritance • Polymorphism • Message Passing
  • 14.
    Objects • OOP usesobjects as its fundamental building blocks. • Objects are the basic run-time entities in an object- oriented system. • Every object is associated with data and functions which define meaningful operations on that object. • Object is a real world existing entity. • Object is an Instance of a particular class.
  • 15.
  • 16.
  • 17.
    Class • Class isa collection of similar objects. • Mango, Apple etc. are objects and their class is Fruit.
  • 18.
    Encapsulation • Wrapping upof data and functions into a single unit (class) is called encapsulation. • Data is not accessible to outside world. • Only those functions which are which are wrapped in the class can access it.
  • 19.
    Data Abstraction • Adata abstraction is a simplified view of an object that includes only features one is interested in while hides away the unnecessary details. • Data abstraction becomes an abstract data type (ADT)or a user-defined type.
  • 20.
    Inheritance • Inheritance isthe mechanism to provides the power of reusability and extendibility. • Inheritance is the process by which one object can acquire the properties of another object. • Types :  Single  Multilevel  Multiple  Hybrid  Hierarchical
  • 21.
  • 22.
    Polymorphism • Poly meansmany. Morphism means forms. • Polymorphism means that the same thing can exist in two forms. • Polymorphism is in short the ability to call different functions by just using one type of function call. • Ex : Bank can be used as - bank (river) - bank (finance)
  • 23.
    Message Passing • Informationor message of one object can be sent to other object. • Object communicate with one another by sending and receiving information much the same way as people communicate with each other. • A message for an object is a request for execution of a proedure and it will invoke a procedure in receiving object that generates the desired result.
  • 24.
    Message Passing • Messagepassing involves specifying the name of the object, the name of the function and the information to be sent. • Ex- employee.salary(name); Object Message Information
  • 25.
    Benefits of OOP •Through inheritance we can extend the use of existing classes. • Build secure program by data hiding. • Message passing techniques for communication between objects make is much simplier. • It is easy to partition the work in a project based on object.
  • 26.
    Applications of OOP •Database management systems • Data security • Artificial intelligence and expert systems • Mobile computing • Real time systems • Simulation and modeling • Distributed computing