0% found this document useful (0 votes)
70 views17 pages

Intro To C++

This document provides an introduction to object-oriented programming (OOP) compared to procedural programming. It discusses key OOP concepts like encapsulation, inheritance, polymorphism, and dynamic binding. Objects are defined as data items that a program must handle, while classes are user-defined data types that define objects. Encapsulation wraps data and functions into a single unit, while inheritance allows objects to inherit properties from other classes. Polymorphism allows operations to exhibit different behaviors depending on the data used.

Uploaded by

gurpreet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views17 pages

Intro To C++

This document provides an introduction to object-oriented programming (OOP) compared to procedural programming. It discusses key OOP concepts like encapsulation, inheritance, polymorphism, and dynamic binding. Objects are defined as data items that a program must handle, while classes are user-defined data types that define objects. Encapsulation wraps data and functions into a single unit, while inheritance allows objects to inherit properties from other classes. Polymorphism allows operations to exhibit different behaviors depending on the data used.

Uploaded by

gurpreet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

C++ PROGRAMMING

INTRODUCTION
Procedure Oriented programming
 Top down approach where program is viewed as a sequence
of tasks to be performed.
 Consists of
 Writing a list of instructions for the computer to follow
 Organize these instructions into groups called functions
 Little attention is paid to data used by the functions
 Inadvertent changes to global data.
 Does not model real world problems
Object Oriented Programming
 “An approach that provides a way of modularizing programs by
creating partitioned memory areas for both data and functions that
can be used as templates for creating copies of such modules on
demand.”
 Data is closely bound to the functions that operate on it and
protects it from modification outside system. Data is not allowed
to flow freely around the system.
 Allows division of problem into a number of entities called
objects. Data of an object is accessed only by the functions
associated with that object.
 Data is hidden in cannot accessed by other functions
 Objects may communicate with each other through functions
 New data and functions can be easily added when needed
 Follows bottom up approach
Communication

Organization of data and functions in OOP


Basic concepts of OOP
 Objects
 Classes
 Data abstraction and encapsulation
 Inheritance
 Polymorphism
 Dynamic binding
 Message Passing
Objects
 Represents any data item that the program has to handle
 Basic runtime entities in a object oriented design
 Objects take up space in memory and have associated address
lie a structure in C
Object: Student
Data:
Name
DOB
Marks
…….
FUNCTIONS
getData
putData
average
Classes
 A collection of objects of similar type
 A user defined data type that defines the entire set of data
and code of an object
 A class is a construct that is used as a blueprint to
create instances of itself – referred to as class instances, class
objects, instance objects or simply objects.
 Once a class is defined multiple instances of it can be created
called objects
Encapsulation
 Encapsulation:
 Wrapping up of data and functions into a single unit is called
encapsulation.
 Data is not accessible to outside world
 Only functions wrapped inside the class can access it.
 Functions provide interface between object data and program
 This insulation of data from direct access by programs is called
info hiding
Data abstraction
 It refers to the act of representing essential features without
including the background details or explanations.
 Classes use the concept of abstraction and are defined as a list
of abstract attributes and function to operate on them.
 They hide all the essential features of objects that are to be
created
 Classes are also called abstract data types.
Inheritance
 Process by which objects of one class acquire the properties
of objects of another class.
 Supports the concept of hierarchical classification.
 Provides reusability
 We can add new features to existing class without modifying
it by deriving a new class from existing one with combined
features of both classes.
Polymorphism
 Ability to take more than one form
 An operation may exhibit different behaviors in different
instances.
 Behaviour depends on data used in the operation
 Operator overloading
 Function Overloading
 Allows objects to have different internal structures and share
the same external structures
Dynamic Binding
 Linking of a procedure call to the code to be executed in
response to the call is called binding
 Dynamic binding means that the code associated with the
function call is not known till run time.
Message Passing
 Objects communicate with one another by sending and
receiving info.
 A message for an object is a request for execution of a
procedure and therefore will invoke a function in the
receiving object
 Message passing involves
 Specifying the name of the object,
 The name of the function
 Info to be sent.
employee.salary(name)

object message information


Benefits of OOP
 Elimination of code redundancy
 Statdard wrking models can be created
 Secure programs
 Multiple instances of an object can be created
 Easier to partition projects based on objects
 Easy upgradation
 Message passing makes communication between objects
easier.
 Software complexity can be easily managed.
Object based Programming Languages
 Style of programming that supports encapsulation and object
identity
 Support programming with objects
 Donot support inheritance and dynamic binding
 Ada
Applications of OOP
 Real Time systems
 Simulation & Modeling
 Object Oriented Databases
 AI & Expert systems
 Neural Networks & Parallel programming
 DSS, OAS
 CIM/CAM/CAD systems

You might also like