SlideShare a Scribd company logo
1 of 34
Prepared By: Asst. Prof. Sejal Jadav
Unit-1
Principles of Object Oriented Programming Tokens,
expressions & Control Statements
(14 MARKS)
B.C.A & B.Sc.(IT) – 3
CS-13 C++ and Object Oriented
Programming
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Basic Concepts of
OOP
[ Object oriented programming ]
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Objects
•My name is Raj, and I am
an instance/object of class Male. When
we say, Human Being, Male or Female, we
just mean a kind, you, your friend, me we
are the forms of these classes. We have a
physical existence while a class is just a
logical definition. We are the objects.
Prepared By: Asst. Prof. Sejal Jadav
Definition:
•Objects are the basic unit of OOP. They are
instances of class, which have data members
and uses various member functions to
perform tasks.
Prepared By: Asst. Prof. Sejal Jadav
•Basic runtime elements.
•Represents any real world entity.
•[ie – person, place, bank account] or user
defined data[ie – vector, time, lists].
Prepared By: Asst. Prof. Sejal Jadav
Example
class person
{
char name[20];
int id;
public:
void getdetails(){}
};
int main()
{
person p1; // p1 is a object
}
Prepared By: Asst. Prof. Sejal Jadav
Class
•The building block of C++ that leads to
Object-Oriented programming is a Class.
•It is a user-defined data type, which holds
its own data members and member
functions, which can be accessed and used
by creating an instance of that class.
Prepared By: Asst. Prof. Sejal Jadav
For Example:
Prepared By: Asst. Prof. Sejal Jadav
•A class is like a blueprint for an object.
•For Example: Consider the Class of Cars.
•There may be many cars with different names
and brand but all of them will share some
common properties like all of them will have 4
wheels, Speed Limit, Mileage range etc. So
here, Car is the class and wheels, speed limits,
mileage are their properties.
Prepared By: Asst. Prof. Sejal Jadav
•In the above example of class Car, the data
member will be speed limit, mileage etc
and member functions can apply brakes,
increase speed etc.
•We can say that a Class in C++ is a blue-
print representing a group of objects
which shares some common properties
and behaviours.
Prepared By: Asst. Prof. Sejal Jadav
Encapsulation
•In normal terms, Encapsulation is defined
as wrapping up of data and information
under a single unit.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
•In Object-Oriented Programming,
Encapsulation is defined as binding
together the data and the functions that
manipulate them.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
Abstraction
•Data abstraction is one of the most
essential and important features of object-
oriented programming in C++.
•Abstraction means displaying only
essential information and hiding the
details.
Prepared By: Asst. Prof. Sejal Jadav
•Data abstraction refers to providing only
essential information about the data to the
outside world, hiding the background
details or implementation.
Prepared By: Asst. Prof. Sejal Jadav
•Consider a real-life example of a man driving
a car.
•The man only knows that pressing the
accelerators will increase the speed of the car
or applying brakes will stop the car but he
does not know about how on pressing
accelerator the speed is actually increasing, he
does not know about the inner mechanism of the
car or the implementation of accelerator, brakes
etc in the car. This is what abstraction is.
Prepared By: Asst. Prof. Sejal Jadav
Abstraction using Classes:
•We can implement Abstraction in C++ using
classes. The class helps us to group data
members and member functions using
available access specifiers (Public, private
and protected). A Class can decide which
data member will be visible to the outside
world and which is not.
Prepared By: Asst. Prof. Sejal Jadav
Abstraction in Header files:
•One more type of abstraction in C++ can be
header files.
•For example, consider the pow() method
present in math.h header file.
Prepared By: Asst. Prof. Sejal Jadav
•Whenever we need to calculate the power of a
number, we simply call the function pow()
present in the math.h header file and pass the
numbers as arguments without knowing the
underlying algorithm according to which the
function is actually calculating the power of
numbers.
Prepared By: Asst. Prof. Sejal Jadav
Polymorphism
•The word polymorphism means having
many forms. In simple words, we can
define polymorphism as the ability of a
message to be displayed in more than one
form.
Prepared By: Asst. Prof. Sejal Jadav
•A person at the same time can have
different characteristic. Like a man at the
same time is a father, a husband, an
employee. So the same person posses
different behaviour in different situations.
This is called polymorphism
Prepared By: Asst. Prof. Sejal Jadav
•An operation may exhibit different
behaviours in different instances. The
behaviour depends upon the types of data
used in the operation.
•C++ supports operator overloading and
function overloading.
Prepared By: Asst. Prof. Sejal Jadav
•Operator Overloading: The process of
making an operator to exhibit different
behaviours in different instances is known as
operator overloading.
Prepared By: Asst. Prof. Sejal Jadav
•Function Overloading: Function overloading
is using a single function name to perform
different types of tasks.
Polymorphism is extensively used in
implementing inheritance.
Prepared By: Asst. Prof. Sejal Jadav
• Example: Suppose we have
to write a function to add
some integers, some times
there are 2 integers, some
times there are 3 integers.
• We can write the Addition
Method with the same name
having different parameters,
the concerned method will
be called according to
parameters.
Prepared By: Asst. Prof. Sejal Jadav
Inheritance
•The capability of a class to derive properties
and characteristics from another class is
called Inheritance.
•Inheritance is one of the most important
features of Object-Oriented Programming.
Prepared By: Asst. Prof. Sejal Jadav
•Sub Class: The class that inherits
properties from another class is called
Sub class or Derived Class.
•Super Class: The class whose properties
are inherited by sub class is called Base
Class or Super class.
Prepared By: Asst. Prof. Sejal Jadav
•Reusability: Inheritance supports the
concept of “reusability”, i.e. when we want
to create a new class and there is already a
class that includes some of the code that
we want, we can derive our new class from
the existing class.
• By doing this, we are reusing the fields and
methods of the existing class.
Prepared By: Asst. Prof. Sejal Jadav
Example: Dog, Cat, Cow can be Derived
Class of Animal Base Class.
Prepared By: Asst. Prof. Sejal Jadav
•Another example: Considering HumanBeing a
class, which has properties like hands, legs, eyes
etc, and functions like walk, talk, eat, see
etc. Male and Female are also classes, but most
of the properties and functions are included
in HumanBeing, hence they can inherit
everything from class HumanBeing using the
concept of Inheritance.
Prepared By: Asst. Prof. Sejal Jadav
•Inheritance is a way to reuse once written
code again and again. The class which is
inherited is called the Base class & the class
which inherits is called the Derived class.
They are also called parent and child class.
Prepared By: Asst. Prof. Sejal Jadav
•So when, a derived class inherits a base class,
the derived class can use all the functions
which are defined in base class, hence making
code reusable.

More Related Content

Similar to C++ unit-1-part-3

C++ unit-2-part-3
C++ unit-2-part-3C++ unit-2-part-3
C++ unit-2-part-3Jadavsejal
 
C++ unit-2-part-2
C++ unit-2-part-2C++ unit-2-part-2
C++ unit-2-part-2Jadavsejal
 
Introduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxIntroduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxGauravYadav906294
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaPawanMM
 
Creativity vs Best Practices
Creativity vs Best PracticesCreativity vs Best Practices
Creativity vs Best PracticesSupun Dissanayake
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxAtikur Rahman
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptxYashKoli22
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesBalamuruganV28
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Hitesh-Java
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Nuzhat Memon
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallJohn Mulhall
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1Geophery sanga
 

Similar to C++ unit-1-part-3 (20)

C++ unit-2-part-3
C++ unit-2-part-3C++ unit-2-part-3
C++ unit-2-part-3
 
C++ unit-2-part-2
C++ unit-2-part-2C++ unit-2-part-2
C++ unit-2-part-2
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
Introduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptxIntroduction to OOPS in Python bsics-.pptx
Introduction to OOPS in Python bsics-.pptx
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
Session 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with JavaSession 07 - Intro to Object Oriented Programming with Java
Session 07 - Intro to Object Oriented Programming with Java
 
Creativity vs Best Practices
Creativity vs Best PracticesCreativity vs Best Practices
Creativity vs Best Practices
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptx
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
 
130704798265658191
130704798265658191130704798265658191
130704798265658191
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Lecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With PythonLecture 01 - Basic Concept About OOP With Python
Lecture 01 - Basic Concept About OOP With Python
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 

More from Jadavsejal

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassJadavsejal
 
Programming Java Concept of Event Handling
Programming Java Concept of Event HandlingProgramming Java Concept of Event Handling
Programming Java Concept of Event HandlingJadavsejal
 
Programming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingProgramming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingJadavsejal
 
concept of applet and concept of Layout Managers
concept of applet and concept of Layout Managersconcept of applet and concept of Layout Managers
concept of applet and concept of Layout ManagersJadavsejal
 
C++ unit-2-part-1
C++ unit-2-part-1C++ unit-2-part-1
C++ unit-2-part-1Jadavsejal
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15Jadavsejal
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14Jadavsejal
 
C++ unit-1-part-13
C++ unit-1-part-13C++ unit-1-part-13
C++ unit-1-part-13Jadavsejal
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12Jadavsejal
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11Jadavsejal
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10Jadavsejal
 
C++ unit-1-part-9
C++ unit-1-part-9C++ unit-1-part-9
C++ unit-1-part-9Jadavsejal
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8Jadavsejal
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7Jadavsejal
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6Jadavsejal
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5Jadavsejal
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4Jadavsejal
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2Jadavsejal
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1Jadavsejal
 
05_system architecture
05_system architecture05_system architecture
05_system architectureJadavsejal
 

More from Jadavsejal (20)

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone Class
 
Programming Java Concept of Event Handling
Programming Java Concept of Event HandlingProgramming Java Concept of Event Handling
Programming Java Concept of Event Handling
 
Programming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingProgramming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event Handling
 
concept of applet and concept of Layout Managers
concept of applet and concept of Layout Managersconcept of applet and concept of Layout Managers
concept of applet and concept of Layout Managers
 
C++ unit-2-part-1
C++ unit-2-part-1C++ unit-2-part-1
C++ unit-2-part-1
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14
 
C++ unit-1-part-13
C++ unit-1-part-13C++ unit-1-part-13
C++ unit-1-part-13
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10
 
C++ unit-1-part-9
C++ unit-1-part-9C++ unit-1-part-9
C++ unit-1-part-9
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7
 
C++ unit-1-part-6
C++ unit-1-part-6C++ unit-1-part-6
C++ unit-1-part-6
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1
 
05_system architecture
05_system architecture05_system architecture
05_system architecture
 

Recently uploaded

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 

Recently uploaded (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 

C++ unit-1-part-3

  • 1. Prepared By: Asst. Prof. Sejal Jadav Unit-1 Principles of Object Oriented Programming Tokens, expressions & Control Statements (14 MARKS) B.C.A & B.Sc.(IT) – 3 CS-13 C++ and Object Oriented Programming Prepared By: Asst. Prof. Sejal Jadav
  • 2. Prepared By: Asst. Prof. Sejal Jadav Basic Concepts of OOP [ Object oriented programming ]
  • 3. Prepared By: Asst. Prof. Sejal Jadav
  • 4. Prepared By: Asst. Prof. Sejal Jadav Objects •My name is Raj, and I am an instance/object of class Male. When we say, Human Being, Male or Female, we just mean a kind, you, your friend, me we are the forms of these classes. We have a physical existence while a class is just a logical definition. We are the objects.
  • 5. Prepared By: Asst. Prof. Sejal Jadav Definition: •Objects are the basic unit of OOP. They are instances of class, which have data members and uses various member functions to perform tasks.
  • 6. Prepared By: Asst. Prof. Sejal Jadav •Basic runtime elements. •Represents any real world entity. •[ie – person, place, bank account] or user defined data[ie – vector, time, lists].
  • 7. Prepared By: Asst. Prof. Sejal Jadav Example class person { char name[20]; int id; public: void getdetails(){} }; int main() { person p1; // p1 is a object }
  • 8. Prepared By: Asst. Prof. Sejal Jadav Class •The building block of C++ that leads to Object-Oriented programming is a Class. •It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class.
  • 9. Prepared By: Asst. Prof. Sejal Jadav For Example:
  • 10. Prepared By: Asst. Prof. Sejal Jadav •A class is like a blueprint for an object. •For Example: Consider the Class of Cars. •There may be many cars with different names and brand but all of them will share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range etc. So here, Car is the class and wheels, speed limits, mileage are their properties.
  • 11. Prepared By: Asst. Prof. Sejal Jadav •In the above example of class Car, the data member will be speed limit, mileage etc and member functions can apply brakes, increase speed etc. •We can say that a Class in C++ is a blue- print representing a group of objects which shares some common properties and behaviours.
  • 12. Prepared By: Asst. Prof. Sejal Jadav Encapsulation •In normal terms, Encapsulation is defined as wrapping up of data and information under a single unit.
  • 13. Prepared By: Asst. Prof. Sejal Jadav
  • 14. Prepared By: Asst. Prof. Sejal Jadav •In Object-Oriented Programming, Encapsulation is defined as binding together the data and the functions that manipulate them.
  • 15. Prepared By: Asst. Prof. Sejal Jadav
  • 16. Prepared By: Asst. Prof. Sejal Jadav Abstraction •Data abstraction is one of the most essential and important features of object- oriented programming in C++. •Abstraction means displaying only essential information and hiding the details.
  • 17. Prepared By: Asst. Prof. Sejal Jadav •Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
  • 18. Prepared By: Asst. Prof. Sejal Jadav •Consider a real-life example of a man driving a car. •The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car but he does not know about how on pressing accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car. This is what abstraction is.
  • 19. Prepared By: Asst. Prof. Sejal Jadav Abstraction using Classes: •We can implement Abstraction in C++ using classes. The class helps us to group data members and member functions using available access specifiers (Public, private and protected). A Class can decide which data member will be visible to the outside world and which is not.
  • 20. Prepared By: Asst. Prof. Sejal Jadav Abstraction in Header files: •One more type of abstraction in C++ can be header files. •For example, consider the pow() method present in math.h header file.
  • 21. Prepared By: Asst. Prof. Sejal Jadav •Whenever we need to calculate the power of a number, we simply call the function pow() present in the math.h header file and pass the numbers as arguments without knowing the underlying algorithm according to which the function is actually calculating the power of numbers.
  • 22. Prepared By: Asst. Prof. Sejal Jadav Polymorphism •The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form.
  • 23. Prepared By: Asst. Prof. Sejal Jadav •A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behaviour in different situations. This is called polymorphism
  • 24. Prepared By: Asst. Prof. Sejal Jadav •An operation may exhibit different behaviours in different instances. The behaviour depends upon the types of data used in the operation. •C++ supports operator overloading and function overloading.
  • 25. Prepared By: Asst. Prof. Sejal Jadav •Operator Overloading: The process of making an operator to exhibit different behaviours in different instances is known as operator overloading.
  • 26. Prepared By: Asst. Prof. Sejal Jadav •Function Overloading: Function overloading is using a single function name to perform different types of tasks. Polymorphism is extensively used in implementing inheritance.
  • 27. Prepared By: Asst. Prof. Sejal Jadav • Example: Suppose we have to write a function to add some integers, some times there are 2 integers, some times there are 3 integers. • We can write the Addition Method with the same name having different parameters, the concerned method will be called according to parameters.
  • 28. Prepared By: Asst. Prof. Sejal Jadav Inheritance •The capability of a class to derive properties and characteristics from another class is called Inheritance. •Inheritance is one of the most important features of Object-Oriented Programming.
  • 29. Prepared By: Asst. Prof. Sejal Jadav •Sub Class: The class that inherits properties from another class is called Sub class or Derived Class. •Super Class: The class whose properties are inherited by sub class is called Base Class or Super class.
  • 30. Prepared By: Asst. Prof. Sejal Jadav •Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. • By doing this, we are reusing the fields and methods of the existing class.
  • 31. Prepared By: Asst. Prof. Sejal Jadav Example: Dog, Cat, Cow can be Derived Class of Animal Base Class.
  • 32. Prepared By: Asst. Prof. Sejal Jadav •Another example: Considering HumanBeing a class, which has properties like hands, legs, eyes etc, and functions like walk, talk, eat, see etc. Male and Female are also classes, but most of the properties and functions are included in HumanBeing, hence they can inherit everything from class HumanBeing using the concept of Inheritance.
  • 33. Prepared By: Asst. Prof. Sejal Jadav •Inheritance is a way to reuse once written code again and again. The class which is inherited is called the Base class & the class which inherits is called the Derived class. They are also called parent and child class.
  • 34. Prepared By: Asst. Prof. Sejal Jadav •So when, a derived class inherits a base class, the derived class can use all the functions which are defined in base class, hence making code reusable.