SlideShare a Scribd company logo
Chapter 9
Pointers, Virtual functions &
Polymorphism
Page  2
Contents
•Introduction
•Pointers
•Pointers to objects
•this pointers
•pointers to derived class
•virtual functions
•pure virtual function
Page  3
Early Binding or
Compile Time Polymorphism
 The concept of polymorphism is implemented
using overloaded functions and operators.
 The overloaded memberfunctions are selected
forinvoking by matching arguments, both type
and numbers.
 This information is known to the compilerat the
compile time and, therefore, compileris able to
select the appropriate function fora particular
call at the compile time itself.
 This is called early binding orstatic binding or
static linking.
Page  4
Late Binding or
Run Time Polymorphism
class A
{
int x;
public:
void show( ) {……}
};
class B : public A
{
int y;
public:
void show( ) {……}
};
 Since the prototype of
show( ) is the same in
both the places, the
function is not
overloaded and therefore
static binding does not
apply.
 The class resolution
operatoris used to
specify the class while
invoking the functions
with the derived class.
 Appropriate member
function is selected while
the program is running.
Page  5
Late Binding or
Run Time Polymorphism
 The appropriate version of
function will be invoked at
runtime.
 Since the function is linked
with a particularclass
much laterafterthe
compilation, this process is
termed as late binding.
 This also known as
dynamic binding, since the
selection of appropriate
function is done
Polymorphism
Compile time Run time
Function
Overloading
Operator
Overloading
Virtual
Functions
Achieving Polymorphism
Page  6
Pointer To Objects
 item * it_ptr; whereitemis aclass andit_ptris apointerof
typeitem.
 Object pointers are useful in creats objects at run time.
 An object pointercan be used to access the public
members of an object.
Page  7
Pointer To Objects
class item
{
int code;
float price;
public:
void getdata( int a, float b )
{ code =a; price = b;}
void show( void )
{ cout << “Code :” <<
code<<endl;
<< “Price :” << price <<
endl; }
};
item x;
item *ptr = &x;
 We can referto the
memberfunctions of item
in two ways:
 Using dot operatorand
object.
 x.getdata(100,75.50);
 x.show( );
 Using arrow operatorand
object pointer.
 ptr-> getdata(100,
75.50);
 ptr-> show( );
 Since *ptris an alias of x
 (*ptr).show( );
continue…
Page  8
Pointer To Objects
 We can also create the objects using pointers and new
operator as:
 item * ptr = new item ;
 This statement allocates enough memory for the data members in
the object structure and assigns the address of the memory space
to ptr.
 We can also create an array of objects using pointers
 Item *ptr = new item[10];
 Creates memory space for an array of 10 objects of item.
continue…
9
Thank You !!!
By:-Gourav Kottawar
9
Thank You !!!
By:-Gourav Kottawar

More Related Content

What's hot (20)

Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
Docent Education
 
Pointer and polymorphism
Pointer and polymorphismPointer and polymorphism
Pointer and polymorphism
SangeethaSasi1
 
03 function overloading
03 function overloading03 function overloading
03 function overloading
Jasleen Kaur (Chandigarh University)
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
Pranali Chaudhari
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
Deepak Singh
 
Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
Roman Okolovich
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
Pranali Chaudhari
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Kumar Gaurav
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
kiran Patel
 
Compile time polymorphism
Compile time polymorphismCompile time polymorphism
Compile time polymorphism
ForwardBlog Enewzletter
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
Princess Sam
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
Jussi Pohjolainen
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Amir Ali
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
Hadziq Fabroyir
 
expression in cpp
expression in cppexpression in cpp
expression in cpp
gourav kottawar
 
Operator overloading in C++
Operator overloading in C++Operator overloading in C++
Operator overloading in C++
Ilio Catallo
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
gourav kottawar
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
gourav kottawar
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
Pointer and polymorphism
Pointer and polymorphismPointer and polymorphism
Pointer and polymorphism
SangeethaSasi1
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
Deepak Singh
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
C++ concept of Polymorphism
C++ concept of  PolymorphismC++ concept of  Polymorphism
C++ concept of Polymorphism
kiran Patel
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
Princess Sam
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
Jussi Pohjolainen
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Amir Ali
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
Hadziq Fabroyir
 
Operator overloading in C++
Operator overloading in C++Operator overloading in C++
Operator overloading in C++
Ilio Catallo
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
gourav kottawar
 
operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++operator overloading & type conversion in cpp over view || c++
operator overloading & type conversion in cpp over view || c++
gourav kottawar
 

Viewers also liked (20)

pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
rattaj
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
Ganesh Hogade
 
Uid
UidUid
Uid
Tech_MX
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
023henil
 
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Abu Saleh
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
Anil Bapat
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
Kulachi Hansraj Model School Ashok Vihar
 
Inheritance
InheritanceInheritance
Inheritance
Sapna Sharma
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
harman kaur
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Kumar
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Duane Wesley
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
cprogrammings
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
Jussi Pohjolainen
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
Princess Sam
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
OOP in C - Virtual Function (Chinese Version)
OOP in C - Virtual Function (Chinese Version)OOP in C - Virtual Function (Chinese Version)
OOP in C - Virtual Function (Chinese Version)
Kai-Feng Chou
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
baabtra.com - No. 1 supplier of quality freshers
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
rattaj
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
Seminar on polymorphism
Seminar on polymorphismSeminar on polymorphism
Seminar on polymorphism
023henil
 
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Abu Saleh
 
Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++Static and Dynamic polymorphism in C++
Static and Dynamic polymorphism in C++
Anil Bapat
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
operator overloading in c++
operator overloading in c++operator overloading in c++
operator overloading in c++
harman kaur
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
Kumar
 
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
cprogrammings
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
Princess Sam
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
OOP in C - Virtual Function (Chinese Version)
OOP in C - Virtual Function (Chinese Version)OOP in C - Virtual Function (Chinese Version)
OOP in C - Virtual Function (Chinese Version)
Kai-Feng Chou
 
Ad

Similar to pointers, virtual functions and polymorphisms in c++ || in cpp (20)

polymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdfpolymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdf
BapanKar2
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
prabhat kumar
 
Polymorphism in C++ for beginners reference
Polymorphism  in C++ for beginners referencePolymorphism  in C++ for beginners reference
Polymorphism in C++ for beginners reference
21pd23
 
Object Oriented Programming using C++: Ch11 Virtual Functions.pptx
Object Oriented Programming using C++: Ch11 Virtual Functions.pptxObject Oriented Programming using C++: Ch11 Virtual Functions.pptx
Object Oriented Programming using C++: Ch11 Virtual Functions.pptx
RashidFaridChishti
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
Dr. SURBHI SAROHA
 
Object oriented programming slides for presentation
Object oriented programming slides for presentationObject oriented programming slides for presentation
Object oriented programming slides for presentation
abdullahkhann3534
 
Object Oriented Programming (OOP) using C++ - Lecture 4
Object Oriented Programming (OOP) using C++ - Lecture 4Object Oriented Programming (OOP) using C++ - Lecture 4
Object Oriented Programming (OOP) using C++ - Lecture 4
Faculty of Computers and Informatics, Suez Canal University, Ismailia, Egypt
 
this is the concept in C++ under object oriented programming language "POLYMO...
this is the concept in C++ under object oriented programming language "POLYMO...this is the concept in C++ under object oriented programming language "POLYMO...
this is the concept in C++ under object oriented programming language "POLYMO...
sj9399037128
 
Lecture6.ppt
Lecture6.pptLecture6.ppt
Lecture6.ppt
ammu241754
 
Polymorphism.pptthis is oops one of the most important feature polymorphism
Polymorphism.pptthis is oops one of the most important feature polymorphismPolymorphism.pptthis is oops one of the most important feature polymorphism
Polymorphism.pptthis is oops one of the most important feature polymorphism
rgvaryan
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nilesh Dalvi
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
ishan743441
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
SherabGyatso
 
polymorphism
polymorphism polymorphism
polymorphism
Imtiaz Hussain
 
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
Mysteriousexpert
 
polymorphism for b.tech iii year students
polymorphism for b.tech iii year studentspolymorphism for b.tech iii year students
polymorphism for b.tech iii year students
Somesh Kumar
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Prof .Pragati Khade
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
riyawagh2
 
polymorphism ppt
polymorphism pptpolymorphism ppt
polymorphism ppt
sheetal singh
 
polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.
UdayGumre
 
polymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdfpolymorpisum-140106223024-phpapp01.pdf
polymorpisum-140106223024-phpapp01.pdf
BapanKar2
 
Polymorphism in C++ for beginners reference
Polymorphism  in C++ for beginners referencePolymorphism  in C++ for beginners reference
Polymorphism in C++ for beginners reference
21pd23
 
Object Oriented Programming using C++: Ch11 Virtual Functions.pptx
Object Oriented Programming using C++: Ch11 Virtual Functions.pptxObject Oriented Programming using C++: Ch11 Virtual Functions.pptx
Object Oriented Programming using C++: Ch11 Virtual Functions.pptx
RashidFaridChishti
 
Object oriented programming slides for presentation
Object oriented programming slides for presentationObject oriented programming slides for presentation
Object oriented programming slides for presentation
abdullahkhann3534
 
this is the concept in C++ under object oriented programming language "POLYMO...
this is the concept in C++ under object oriented programming language "POLYMO...this is the concept in C++ under object oriented programming language "POLYMO...
this is the concept in C++ under object oriented programming language "POLYMO...
sj9399037128
 
Polymorphism.pptthis is oops one of the most important feature polymorphism
Polymorphism.pptthis is oops one of the most important feature polymorphismPolymorphism.pptthis is oops one of the most important feature polymorphism
Polymorphism.pptthis is oops one of the most important feature polymorphism
rgvaryan
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
ishan743441
 
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
Mysteriousexpert
 
polymorphism for b.tech iii year students
polymorphism for b.tech iii year studentspolymorphism for b.tech iii year students
polymorphism for b.tech iii year students
Somesh Kumar
 
polymorphism.pdf
polymorphism.pdfpolymorphism.pdf
polymorphism.pdf
riyawagh2
 
polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.polymorphism in c++ with Full Explanation.
polymorphism in c++ with Full Explanation.
UdayGumre
 
Ad

More from gourav kottawar (20)

operator overloading & type conversion in cpp
operator overloading & type conversion in cppoperator overloading & type conversion in cpp
operator overloading & type conversion in cpp
gourav kottawar
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
gourav kottawar
 
classes & objects in cpp
classes & objects in cppclasses & objects in cpp
classes & objects in cpp
gourav kottawar
 
expression in cpp
expression in cppexpression in cpp
expression in cpp
gourav kottawar
 
basics of c++
basics of c++basics of c++
basics of c++
gourav kottawar
 
working file handling in cpp overview
working file handling in cpp overviewworking file handling in cpp overview
working file handling in cpp overview
gourav kottawar
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cpp
gourav kottawar
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basics
gourav kottawar
 
basics of c++
basics of c++basics of c++
basics of c++
gourav kottawar
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sql
gourav kottawar
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slides
gourav kottawar
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overview
gourav kottawar
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
gourav kottawar
 
Relational Model in dbms & sql database
Relational Model in dbms & sql databaseRelational Model in dbms & sql database
Relational Model in dbms & sql database
gourav kottawar
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 
security and privacy in dbms and in sql database
security and privacy in dbms and in sql databasesecurity and privacy in dbms and in sql database
security and privacy in dbms and in sql database
gourav kottawar
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)
gourav kottawar
 
Software documentation
Software documentationSoftware documentation
Software documentation
gourav kottawar
 
Software reengineering
Software reengineeringSoftware reengineering
Software reengineering
gourav kottawar
 
Organizational behaviour
Organizational behaviourOrganizational behaviour
Organizational behaviour
gourav kottawar
 
operator overloading & type conversion in cpp
operator overloading & type conversion in cppoperator overloading & type conversion in cpp
operator overloading & type conversion in cpp
gourav kottawar
 
constructor & destructor in cpp
constructor & destructor in cppconstructor & destructor in cpp
constructor & destructor in cpp
gourav kottawar
 
classes & objects in cpp
classes & objects in cppclasses & objects in cpp
classes & objects in cpp
gourav kottawar
 
working file handling in cpp overview
working file handling in cpp overviewworking file handling in cpp overview
working file handling in cpp overview
gourav kottawar
 
exception handling in cpp
exception handling in cppexception handling in cpp
exception handling in cpp
gourav kottawar
 
cpp input & output system basics
cpp input & output system basicscpp input & output system basics
cpp input & output system basics
gourav kottawar
 
SQL || overview and detailed information about Sql
SQL || overview and detailed information about SqlSQL || overview and detailed information about Sql
SQL || overview and detailed information about Sql
gourav kottawar
 
SQL querys in detail || Sql query slides
SQL querys in detail || Sql query slidesSQL querys in detail || Sql query slides
SQL querys in detail || Sql query slides
gourav kottawar
 
Rrelational algebra in dbms overview
Rrelational algebra in dbms overviewRrelational algebra in dbms overview
Rrelational algebra in dbms overview
gourav kottawar
 
overview of database concept
overview of database conceptoverview of database concept
overview of database concept
gourav kottawar
 
Relational Model in dbms & sql database
Relational Model in dbms & sql databaseRelational Model in dbms & sql database
Relational Model in dbms & sql database
gourav kottawar
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 
security and privacy in dbms and in sql database
security and privacy in dbms and in sql databasesecurity and privacy in dbms and in sql database
security and privacy in dbms and in sql database
gourav kottawar
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)
gourav kottawar
 
Organizational behaviour
Organizational behaviourOrganizational behaviour
Organizational behaviour
gourav kottawar
 

Recently uploaded (20)

Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
Pragya Champion's Chalice 2025 Set , General Quiz
Pragya Champion's Chalice 2025 Set , General QuizPragya Champion's Chalice 2025 Set , General Quiz
Pragya Champion's Chalice 2025 Set , General Quiz
Pragya - UEM Kolkata Quiz Club
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
LDMMIA Bonus GUEST GRAD Student Check-in
LDMMIA Bonus GUEST GRAD Student Check-inLDMMIA Bonus GUEST GRAD Student Check-in
LDMMIA Bonus GUEST GRAD Student Check-in
LDM & Mia eStudios
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Semisolid_Dosage_Forms.pptx
Semisolid_Dosage_Forms.pptxSemisolid_Dosage_Forms.pptx
Semisolid_Dosage_Forms.pptx
Shantanu Ranjan
 
Diana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda - A Wauconda-Based EducatorDiana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time OffHow to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time Off
Celine George
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
LDMMIA Bonus GUEST GRAD Student Check-in
LDMMIA Bonus GUEST GRAD Student Check-inLDMMIA Bonus GUEST GRAD Student Check-in
LDMMIA Bonus GUEST GRAD Student Check-in
LDM & Mia eStudios
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
Semisolid_Dosage_Forms.pptx
Semisolid_Dosage_Forms.pptxSemisolid_Dosage_Forms.pptx
Semisolid_Dosage_Forms.pptx
Shantanu Ranjan
 
Diana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda - A Wauconda-Based EducatorDiana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda - A Wauconda-Based Educator
Diana Enriquez Wauconda
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Dashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo SlidesDashboard Overview in Odoo 18 - Odoo Slides
Dashboard Overview in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time OffHow to Manage Allocations in Odoo 18 Time Off
How to Manage Allocations in Odoo 18 Time Off
Celine George
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
How to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 WebsiteHow to Configure Add to Cart in Odoo 18 Website
How to Configure Add to Cart in Odoo 18 Website
Celine George
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 

pointers, virtual functions and polymorphisms in c++ || in cpp

  • 1. Chapter 9 Pointers, Virtual functions & Polymorphism
  • 2. Page  2 Contents •Introduction •Pointers •Pointers to objects •this pointers •pointers to derived class •virtual functions •pure virtual function
  • 3. Page  3 Early Binding or Compile Time Polymorphism  The concept of polymorphism is implemented using overloaded functions and operators.  The overloaded memberfunctions are selected forinvoking by matching arguments, both type and numbers.  This information is known to the compilerat the compile time and, therefore, compileris able to select the appropriate function fora particular call at the compile time itself.  This is called early binding orstatic binding or static linking.
  • 4. Page  4 Late Binding or Run Time Polymorphism class A { int x; public: void show( ) {……} }; class B : public A { int y; public: void show( ) {……} };  Since the prototype of show( ) is the same in both the places, the function is not overloaded and therefore static binding does not apply.  The class resolution operatoris used to specify the class while invoking the functions with the derived class.  Appropriate member function is selected while the program is running.
  • 5. Page  5 Late Binding or Run Time Polymorphism  The appropriate version of function will be invoked at runtime.  Since the function is linked with a particularclass much laterafterthe compilation, this process is termed as late binding.  This also known as dynamic binding, since the selection of appropriate function is done Polymorphism Compile time Run time Function Overloading Operator Overloading Virtual Functions Achieving Polymorphism
  • 6. Page  6 Pointer To Objects  item * it_ptr; whereitemis aclass andit_ptris apointerof typeitem.  Object pointers are useful in creats objects at run time.  An object pointercan be used to access the public members of an object.
  • 7. Page  7 Pointer To Objects class item { int code; float price; public: void getdata( int a, float b ) { code =a; price = b;} void show( void ) { cout << “Code :” << code<<endl; << “Price :” << price << endl; } }; item x; item *ptr = &x;  We can referto the memberfunctions of item in two ways:  Using dot operatorand object.  x.getdata(100,75.50);  x.show( );  Using arrow operatorand object pointer.  ptr-> getdata(100, 75.50);  ptr-> show( );  Since *ptris an alias of x  (*ptr).show( ); continue…
  • 8. Page  8 Pointer To Objects  We can also create the objects using pointers and new operator as:  item * ptr = new item ;  This statement allocates enough memory for the data members in the object structure and assigns the address of the memory space to ptr.  We can also create an array of objects using pointers  Item *ptr = new item[10];  Creates memory space for an array of 10 objects of item. continue…