SlideShare uma empresa Scribd logo
1 de 26
OOPs with C++
Ms. Sudhriti Sengupta
&
Dr. Lavanya Sharma
OOPS
Object-Oriented Programming or OOPs refers to
languages that uses objects in programming.
Object-oriented programming aims to
implement real-world entities like inheritance,
hiding, polymorphism etc in programming. The
main aim of OOP is to bind together the data
and the functions that operate on them so that
no other part of the code can access this data
except that function.
Principle of OOPS
• Object
This is the basic unit of object oriented
programming. That is both data and function that
operate on data are bundled as a unit called as
object.
• Class
When you define a class, you define a blueprint for
an object. This doesn't actually define any data, but
it does define what the class name means, that is,
what an object of the class will consist of and what
operations can be performed on such an object.
• Abstraction
Data abstraction refers to, providing only essential
information to the outside world and hiding their
background details, i.e., to represent the needed
information in program without presenting the details.
For example, a database system hides certain details of
how data is stored and created and maintained. Similar
way, C++ classes provides different methods to the
outside world without giving internal detail about those
methods and data.
Encapsulation
Encapsulation is placing the data and the
functions that work on that data in the same
place. While working with procedural languages,
it is not always clear which functions work on
which variables but object-oriented
programming provides you framework to place
the data and the relevant functions together in
the same object.
Inheritance
One of the most useful aspects of object-
oriented programming is code reusability. As the
name suggests Inheritance is the process of
forming a new class from an existing class that is
from the existing class called as base class, new
class is formed called as derived class.
This is a very important concept of object-
oriented programming since this feature helps
to reduce the code size.
Important terminology:Inheritance
•
Super Class: The class whose features are inherited is
known as superclass(or a base class or a parent class).
• Sub Class: The class that inherits the other class is known
as subclass(or a derived class, extended class, or child
class). The subclass can add its own fields and methods in
addition to the superclass fields and methods.
• 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.
Polymorphism
The ability to use an operator or function in
different ways in other words giving different
meaning or functions to the operators or
functions is called polymorphism. Poly refers to
many. That is a single function or an operator
functioning in many ways different upon the
usage is called polymorphism.
Introduction to C++
C++ is a middle-level programming language
developed by Bjarne Stroustrup starting in 1979
at Bell Labs. C++ runs on a variety of platforms,
such as Windows, Mac OS, and the various
versions of UNIX.
Use of C++
• C++ is used by hundreds of thousands of programmers
in essentially every application domain.
• C++ is being highly used to write device drivers and
other software that rely on direct manipulation of
hardware under realtime constraints.
• C++ is widely used for teaching and research because it
is clean enough for successful teaching of basic
concepts.
• Anyone who has used either an Apple Macintosh or a
PC running Windows has indirectly used C++ because
the primary user interfaces of these systems are
written in C++.
Points to NOTE
• C++ is a statically typed, compiled, general-
purpose, case-sensitive, free-form programming
language that supports procedural, object-
oriented, and generic programming.
• C++ is regarded as a middle-level language, as it
comprises a combination of both high-level and
low-level language features.
• C++ is a superset of C, and that virtually any legal
C program is a legal C++ program.
Polymorhpism
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.
Real life example of polymorphism, a person at the
same time can have different characteristic. Like a lady at
the same time is a mother, a daughter, a teacher etc . So
the same person posses different behavior in different
situations. This is called polymorphism.
Polymorphism is considered as one of the important
features of Object Oriented Programming.
• Compile time polymorphism: The overloaded
functions are invoked by matching the type
and number of arguments. This information is
available at the compile time and, therefore,
compiler selects the appropriate function at
the compile time. It is achieved by function
overloading and operator overloading which is
also known as static binding or early binding.
Now, let's consider the case where function
name and prototype is same.
Compile time polymorphism: This type of
polymorphism is achieved by function
overloading or operator overloading.
Function Overloading: When there are multiple
functions with same name but different
parameters then these functions are said to
be overloaded. Functions can be overloaded
by change in number of
arguments or/and change in type of arguments.
Operator Overloading: C++ also provide option
to overload operators. For example, we can
make the operator (‘+’) for string class to
concatenate two strings. We know that this is
the addition operator whose task is to add two
operands. So a single operator ‘+’ when placed
between integer operands , adds them and
when placed between string operands,
concatenates them.
• Run time polymorphism: Run time
polymorphism is achieved when the object's
method is invoked at the run time instead of
compile time. It is achieved by method
overriding which is also known as dynamic
binding or late binding.
Runtime polymorphism: This type of
polymorphism is achieved by Function
Overriding.Function overriding on the other
hand occurs when a derived class has a
definition for one of the member functions of
the base class. That base function is said to
be overridden.
Compile time polymorphism Run time polymorphism
The function to be invoked is
known at the compile time.
The function to be invoked is
known at the run time.
It is also known as overloading,
early binding and static binding.
It is also known as overriding,
Dynamic binding and late binding.
Overloading is a compile time
polymorphism where more than
one method is having the same
name but with the different
number of parameters or the type
of the parameters.
Overriding is a run time
polymorphism where more than
one method is having the same
name, number of parameters and
the type of the parameters.
It is achieved by function
overloading and operator
overloading.
It is achieved by virtual functions
and pointers.
It provides fast execution as it is
known at the compile time.
It provides slow execution as it is
known at the run time.
It is less flexible as mainly all the
things execute at the compile
time.
It is more flexible as all the things
execute at the run time.
Simple program for function
overloading
• // Program to compute absolute value
• // Works both for integer and float
• #include <iostream>
• using namespace std;
• int absolute(int);
• float absolute(float);
• int main() {
• int a = -5;
• float b = 5.5;
•
• cout << "Absolute value of " << a << " = " << absolute(a) << endl;
• cout << "Absolute value of " << b << " = " << absolute(b);
• return 0;
• }
• int absolute(int var) {
• if (var < 0)
• var = -var;
• return var;
• }
• float absolute(float var){
• if (var < 0.0)
• var = -var;
• return var;
• }

Mais conteúdo relacionado

Mais procurados

Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowRanel Padon
 
C++ to java
C++ to javaC++ to java
C++ to javaAjmal Ak
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++KurdGul
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Anwar Ul Haq
 
Python Programming - I. Introduction
Python Programming - I. IntroductionPython Programming - I. Introduction
Python Programming - I. IntroductionRanel Padon
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesUmesh Nikam
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPTShivam Gupta
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Abdul Hannan
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.Nicholas Pringle
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsDirecti Group
 
Type hints in python & mypy
Type hints in python & mypyType hints in python & mypy
Type hints in python & mypyAnirudh
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of VariableMOHIT DADU
 
Python Crash Course
Python Crash CoursePython Crash Course
Python Crash CourseHaim Michael
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#Sagar Pednekar
 

Mais procurados (19)

C++vs java
C++vs javaC++vs java
C++vs java
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the Flow
 
C++ to java
C++ to javaC++ to java
C++ to java
 
Python programming
Python programmingPython programming
Python programming
 
Intro. to prog. c++
Intro. to prog. c++Intro. to prog. c++
Intro. to prog. c++
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1
 
Python Programming - I. Introduction
Python Programming - I. IntroductionPython Programming - I. Introduction
Python Programming - I. Introduction
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Programming
ProgrammingProgramming
Programming
 
Java chapter 3
Java   chapter 3Java   chapter 3
Java chapter 3
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.
 
Object oriented concepts ppt
Object oriented concepts pptObject oriented concepts ppt
Object oriented concepts ppt
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Type hints in python & mypy
Type hints in python & mypyType hints in python & mypy
Type hints in python & mypy
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
 
Python Crash Course
Python Crash CoursePython Crash Course
Python Crash Course
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 

Semelhante a C++ first s lide

Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
Programming Language
Programming  LanguageProgramming  Language
Programming LanguageAdeel Hamid
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++KAUSHAL KUMAR JHA
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptxPadmaN24
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionRai University
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals umesh patil
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionRai University
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionSamuelAnsong6
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP IntroductionHashni T
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++Mohamed Essam
 

Semelhante a C++ first s lide (20)

The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
Object oriented programing
Object oriented programingObject oriented programing
Object oriented programing
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
M.c.a (sem iii) paper - i - object oriented programming
M.c.a (sem   iii) paper - i - object oriented programmingM.c.a (sem   iii) paper - i - object oriented programming
M.c.a (sem iii) paper - i - object oriented programming
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptx
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
 
My c++
My c++My c++
My c++
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
73d32 session1 c++
73d32 session1 c++73d32 session1 c++
73d32 session1 c++
 

Último

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfsmsksolar
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 

Último (20)

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 

C++ first s lide

  • 1. OOPs with C++ Ms. Sudhriti Sengupta & Dr. Lavanya Sharma
  • 2. OOPS Object-Oriented Programming or OOPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
  • 3.
  • 4. Principle of OOPS • Object This is the basic unit of object oriented programming. That is both data and function that operate on data are bundled as a unit called as object. • Class When you define a class, you define a blueprint for an object. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object.
  • 5. • Abstraction Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details. For example, a database system hides certain details of how data is stored and created and maintained. Similar way, C++ classes provides different methods to the outside world without giving internal detail about those methods and data.
  • 6.
  • 7. Encapsulation Encapsulation is placing the data and the functions that work on that data in the same place. While working with procedural languages, it is not always clear which functions work on which variables but object-oriented programming provides you framework to place the data and the relevant functions together in the same object.
  • 8.
  • 9. Inheritance One of the most useful aspects of object- oriented programming is code reusability. As the name suggests Inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class. This is a very important concept of object- oriented programming since this feature helps to reduce the code size.
  • 10. Important terminology:Inheritance • Super Class: The class whose features are inherited is known as superclass(or a base class or a parent class). • Sub Class: The class that inherits the other class is known as subclass(or a derived class, extended class, or child class). The subclass can add its own fields and methods in addition to the superclass fields and methods. • 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.
  • 11.
  • 12. Polymorphism The ability to use an operator or function in different ways in other words giving different meaning or functions to the operators or functions is called polymorphism. Poly refers to many. That is a single function or an operator functioning in many ways different upon the usage is called polymorphism.
  • 13.
  • 14. Introduction to C++ C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
  • 15. Use of C++ • C++ is used by hundreds of thousands of programmers in essentially every application domain. • C++ is being highly used to write device drivers and other software that rely on direct manipulation of hardware under realtime constraints. • C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts. • Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++.
  • 16. Points to NOTE • C++ is a statically typed, compiled, general- purpose, case-sensitive, free-form programming language that supports procedural, object- oriented, and generic programming. • C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. • C++ is a superset of C, and that virtually any legal C program is a legal C++ program.
  • 18. 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. Real life example of polymorphism, a person at the same time can have different characteristic. Like a lady at the same time is a mother, a daughter, a teacher etc . So the same person posses different behavior in different situations. This is called polymorphism. Polymorphism is considered as one of the important features of Object Oriented Programming.
  • 19.
  • 20. • Compile time polymorphism: The overloaded functions are invoked by matching the type and number of arguments. This information is available at the compile time and, therefore, compiler selects the appropriate function at the compile time. It is achieved by function overloading and operator overloading which is also known as static binding or early binding. Now, let's consider the case where function name and prototype is same.
  • 21. Compile time polymorphism: This type of polymorphism is achieved by function overloading or operator overloading. Function Overloading: When there are multiple functions with same name but different parameters then these functions are said to be overloaded. Functions can be overloaded by change in number of arguments or/and change in type of arguments.
  • 22. Operator Overloading: C++ also provide option to overload operators. For example, we can make the operator (‘+’) for string class to concatenate two strings. We know that this is the addition operator whose task is to add two operands. So a single operator ‘+’ when placed between integer operands , adds them and when placed between string operands, concatenates them.
  • 23. • Run time polymorphism: Run time polymorphism is achieved when the object's method is invoked at the run time instead of compile time. It is achieved by method overriding which is also known as dynamic binding or late binding.
  • 24. Runtime polymorphism: This type of polymorphism is achieved by Function Overriding.Function overriding on the other hand occurs when a derived class has a definition for one of the member functions of the base class. That base function is said to be overridden.
  • 25. Compile time polymorphism Run time polymorphism The function to be invoked is known at the compile time. The function to be invoked is known at the run time. It is also known as overloading, early binding and static binding. It is also known as overriding, Dynamic binding and late binding. Overloading is a compile time polymorphism where more than one method is having the same name but with the different number of parameters or the type of the parameters. Overriding is a run time polymorphism where more than one method is having the same name, number of parameters and the type of the parameters. It is achieved by function overloading and operator overloading. It is achieved by virtual functions and pointers. It provides fast execution as it is known at the compile time. It provides slow execution as it is known at the run time. It is less flexible as mainly all the things execute at the compile time. It is more flexible as all the things execute at the run time.
  • 26. Simple program for function overloading • // Program to compute absolute value • // Works both for integer and float • #include <iostream> • using namespace std; • int absolute(int); • float absolute(float); • int main() { • int a = -5; • float b = 5.5; • • cout << "Absolute value of " << a << " = " << absolute(a) << endl; • cout << "Absolute value of " << b << " = " << absolute(b); • return 0; • } • int absolute(int var) { • if (var < 0) • var = -var; • return var; • } • float absolute(float var){ • if (var < 0.0) • var = -var; • return var; • }