SlideShare a Scribd company logo
5
A pointer is a derived data type that refers to another data variable by
storing the variable is memory address rather than data declaring and
initialing pointers.
 DECLARING AND INITIALIZING POINTER
We can declare a pointer variable similar to other variables in C++.
 MANIPULATION OF POINTER
We can manipulate a pointer with the indirection operator . I e., which is
also known as deference operator.
Syntax: data_ type * pointer _variable
Syntax:*pointer _ variable
Most read
10
Example:
#include< iostream. h>
#include<conio.h>
Class test
{private:
Int x;
Public:
Void set x(int x)
{this->x=x;}
void print(){ cout<<“x=“};
int main()
{
Test obj;
Int x=20;
Obj. setx(x);
Obj . print();
Return 0;}
 This this pointer is a constant
pointer that holds the memory
address of the current object
,The this pointer is not
available in static member
functions can be called
without any object. static
member functions can be
called with class name.
OUTPUT: X=20
Most read
11
All derived classes inherit properties from the common
base class. Pointers can be declared to the point base or
derived class. pointers to objects of the base class are type
compatible with pointers to objects of derived class .A
base class pointer can point to objects of both the baseand
derived class.
B*cptr; //pointer to class b type variable
B b; / /base object
D d; //derived object
Cptr=&b; //cptr points to object b
Cptr=&d; //cptr points to object d
Most read
Pointers,virtual functions and polymorphism cpp
 POLYMORPHISM
 POINTERS
 POINTERS TO OBJECT
 THIS POINTER
 POINTERS TO DERIVED CLASSES
 VIRTUAL FUNCTIONS
 PURE VIRUAL FUNCTIONS
Polymorphism is one of the crucial features of OOP.It simply means one
name, multiple forms. We have already seen how the concept of
polymorphism is implemented using the overload functions and
operators.
EXAMPLE:
Class A
{
Int x;
Public:
Void show() {……}//show in base class
};
Class B:public A
{
Int y;
Public:
Void show() {….}//show in derives class
};
POLYMORPHISM
Compile time
polymorphism
Run time
polymorphism
Function
overloading
Operator
overloading
Virtual
function
A pointer is a derived data type that refers to another data variable by
storing the variable is memory address rather than data declaring and
initialing pointers.
 DECLARING AND INITIALIZING POINTER
We can declare a pointer variable similar to other variables in C++.
 MANIPULATION OF POINTER
We can manipulate a pointer with the indirection operator . I e., which is
also known as deference operator.
Syntax: data_ type * pointer _variable
Syntax:*pointer _ variable
 POINTER EXPRESSION AND POINTER
ARITHMETIC
There are a substantial number of arithmetic operations that be Performed
with pointers.
o A pointer can be incremented(++)(or)decrement(--).
o Any integer can be added to or subtracted from a pointer.
o One pointer can be subtracted from another .
Example:
int a[6]; k
int*aptr;
aptr=&a[0];
 USING POINTERS WITH ARRAYS AND STRINGS
Pointers is one of the efficient to access elements of an
array. pointers are useful to allocate arrays dynamically.
I .e, we can decide the array size at run time.
We can declare the pointers to array as follows
int*nptr ;
nptr =number[0]; (or) nptr=number;
 ARRAY OF POINTER
The array of pointers represents a collection of address. by declaring array of
pointers we can save a subtantial amount of memory space.
 POINTERS AND STRINGS
C++ also allows us to handle the special kind of arrays, I e, strings with pointers.
we known that a string is one dimensional array of character, which start with
the index “0” and end with the null character in C++.
Syntax: Int*in array[10]
Syntax: char num[]=”one”;
Const char *number=”one”;
 POINTERS TO FUNCTIONS
The pointer to function is known as callback function, we can use these
function pointers to refer to a function. using function pointers ,we can allow
a C++ program to select a function dynamically at run time.
POINTER USING C++:
#include<iostream.h>
#include<conio.h>
Void main( )
{
Int a,*ptr1;
Ptr1=&a;
Cout<<“The address of a:”<<ptr1<<“/n”;
Getch( );
}
Syntax: data_type(*function_ name);
As started earlier ,a pointer can point to an object created by a
class item x; when item is and x is an object defined to be of
type item. similarly we can define a pointer.
Example:
class item
{
Int code;Float price;
Public:
Void getdata(int a, float b)
{Code=a; price=b;}
Void show(void)
{cout<<“code:”<<code<<“/n”;
Cout<<“price:”<<price<<“/n”;}
};
item*it_ ptr;
Example:
#include< iostream. h>
#include<conio.h>
Class test
{private:
Int x;
Public:
Void set x(int x)
{this->x=x;}
void print(){ cout<<“x=“};
int main()
{
Test obj;
Int x=20;
Obj. setx(x);
Obj . print();
Return 0;}
 This this pointer is a constant
pointer that holds the memory
address of the current object
,The this pointer is not
available in static member
functions can be called
without any object. static
member functions can be
called with class name.
OUTPUT: X=20
All derived classes inherit properties from the common
base class. Pointers can be declared to the point base or
derived class. pointers to objects of the base class are type
compatible with pointers to objects of derived class .A
base class pointer can point to objects of both the baseand
derived class.
B*cptr; //pointer to class b type variable
B b; / /base object
D d; //derived object
Cptr=&b; //cptr points to object b
Cptr=&d; //cptr points to object d
A virtual function is a member function that you expect to
Be refined in derived classes. When you refer to a derived
Class objects using a pointer or a reference to the base
class, you can call a virtual function for that object and
execute the derived class's version of the function.
Pointers,virtual functions and polymorphism cpp
Pure virtual function is also known as abstract
function. A class with at least one Pure virtual
function or abstract function is called abstract
class. We can’t create an member function
of abstract class will be invoked by derived class
object.
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp

More Related Content

What's hot (20)

Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
Haresh Jaiswal
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 
Member Function in C++
Member Function in C++ Member Function in C++
Member Function in C++
NikitaKaur10
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
Vishesh Jha
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
Dr-Dipali Meher
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
Sujan Mia
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
University of Madras
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
Kamal Acharya
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptx
RAGAVIC2
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
Madishetty Prathibha
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
Nilesh Dalvi
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vishal Patil
 
Member Function in C++
Member Function in C++ Member Function in C++
Member Function in C++
NikitaKaur10
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
rprajat007
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
Vishesh Jha
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
Sujan Mia
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Array of objects.pptx
Array of objects.pptxArray of objects.pptx
Array of objects.pptx
RAGAVIC2
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 

Similar to Pointers,virtual functions and polymorphism cpp (20)

pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphism
ramya marichamy
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
rattaj
 
OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)OOPS & C++(UNIT 4)
OOPS & C++(UNIT 4)
Dr. SURBHI SAROHA
 
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
Mysteriousexpert
 
Pointer and polymorphism
Pointer and polymorphismPointer and polymorphism
Pointer and polymorphism
SangeethaSasi1
 
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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
SherabGyatso
 
Presentations_PPT_ Unit-6_OOP.pptx
Presentations_PPT_                   Unit-6_OOP.pptxPresentations_PPT_                   Unit-6_OOP.pptx
Presentations_PPT_ Unit-6_OOP.pptx
ZeelGoyani
 
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
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nilesh Dalvi
 
Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
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
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
Gamindu Udayanga
 
Object oriented programming slides for presentation
Object oriented programming slides for presentationObject oriented programming slides for presentation
Object oriented programming slides for presentation
abdullahkhann3534
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Abu Saleh
 
22 scheme OOPs with C++ BCS306B_module4.pdf
22 scheme  OOPs with C++ BCS306B_module4.pdf22 scheme  OOPs with C++ BCS306B_module4.pdf
22 scheme OOPs with C++ BCS306B_module4.pdf
sindhus795217
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
prabhat kumar
 
CS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2ndCS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2nd
Edward Chen
 
Pointers
PointersPointers
Pointers
Prof. Dr. K. Adisesha
 
Virtual Function
Virtual FunctionVirtual Function
Virtual Function
Lovely Professional University
 
pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphism
ramya marichamy
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
rattaj
 
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
6be10b153306cc41e65403247a14a4dba5f9186aCHAPTER 2_POINTERS, VIRTUAL FUNCTIONS...
Mysteriousexpert
 
Pointer and polymorphism
Pointer and polymorphismPointer and polymorphism
Pointer and polymorphism
SangeethaSasi1
 
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
 
Presentations_PPT_ Unit-6_OOP.pptx
Presentations_PPT_                   Unit-6_OOP.pptxPresentations_PPT_                   Unit-6_OOP.pptx
Presentations_PPT_ Unit-6_OOP.pptx
ZeelGoyani
 
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
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
Gamindu Udayanga
 
Object oriented programming slides for presentation
Object oriented programming slides for presentationObject oriented programming slides for presentation
Object oriented programming slides for presentation
abdullahkhann3534
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Abu Saleh
 
22 scheme OOPs with C++ BCS306B_module4.pdf
22 scheme  OOPs with C++ BCS306B_module4.pdf22 scheme  OOPs with C++ BCS306B_module4.pdf
22 scheme OOPs with C++ BCS306B_module4.pdf
sindhus795217
 
CS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2ndCS225_Prelecture_Notes 2nd
CS225_Prelecture_Notes 2nd
Edward Chen
 
Ad

More from rajshreemuthiah (20)

oracle
oracleoracle
oracle
rajshreemuthiah
 
quality
qualityquality
quality
rajshreemuthiah
 
bigdata
bigdatabigdata
bigdata
rajshreemuthiah
 
polymorphism
polymorphismpolymorphism
polymorphism
rajshreemuthiah
 
solutions and understanding text analytics
solutions and understanding text analyticssolutions and understanding text analytics
solutions and understanding text analytics
rajshreemuthiah
 
interface
interfaceinterface
interface
rajshreemuthiah
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
rajshreemuthiah
 
concurrency control
concurrency controlconcurrency control
concurrency control
rajshreemuthiah
 
Education
EducationEducation
Education
rajshreemuthiah
 
Formal verification
Formal verificationFormal verification
Formal verification
rajshreemuthiah
 
Transaction management
Transaction management Transaction management
Transaction management
rajshreemuthiah
 
Multi thread
Multi threadMulti thread
Multi thread
rajshreemuthiah
 
System testing
System testingSystem testing
System testing
rajshreemuthiah
 
software maintenance
software maintenancesoftware maintenance
software maintenance
rajshreemuthiah
 
exception handling
exception handlingexception handling
exception handling
rajshreemuthiah
 
e governance
e governancee governance
e governance
rajshreemuthiah
 
recovery management
recovery managementrecovery management
recovery management
rajshreemuthiah
 
Implementing polymorphism
Implementing polymorphismImplementing polymorphism
Implementing polymorphism
rajshreemuthiah
 
Buffer managements
Buffer managementsBuffer managements
Buffer managements
rajshreemuthiah
 
os linux
os linuxos linux
os linux
rajshreemuthiah
 
Ad

Recently uploaded (20)

Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf7 Salesforce Data Cloud Best Practices.pdf
7 Salesforce Data Cloud Best Practices.pdf
Minuscule Technologies
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdfvertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 

Pointers,virtual functions and polymorphism cpp

  • 2.  POLYMORPHISM  POINTERS  POINTERS TO OBJECT  THIS POINTER  POINTERS TO DERIVED CLASSES  VIRTUAL FUNCTIONS  PURE VIRUAL FUNCTIONS
  • 3. Polymorphism is one of the crucial features of OOP.It simply means one name, multiple forms. We have already seen how the concept of polymorphism is implemented using the overload functions and operators. EXAMPLE: Class A { Int x; Public: Void show() {……}//show in base class }; Class B:public A { Int y; Public: Void show() {….}//show in derives class };
  • 5. A pointer is a derived data type that refers to another data variable by storing the variable is memory address rather than data declaring and initialing pointers.  DECLARING AND INITIALIZING POINTER We can declare a pointer variable similar to other variables in C++.  MANIPULATION OF POINTER We can manipulate a pointer with the indirection operator . I e., which is also known as deference operator. Syntax: data_ type * pointer _variable Syntax:*pointer _ variable
  • 6.  POINTER EXPRESSION AND POINTER ARITHMETIC There are a substantial number of arithmetic operations that be Performed with pointers. o A pointer can be incremented(++)(or)decrement(--). o Any integer can be added to or subtracted from a pointer. o One pointer can be subtracted from another . Example: int a[6]; k int*aptr; aptr=&a[0];  USING POINTERS WITH ARRAYS AND STRINGS Pointers is one of the efficient to access elements of an array. pointers are useful to allocate arrays dynamically. I .e, we can decide the array size at run time.
  • 7. We can declare the pointers to array as follows int*nptr ; nptr =number[0]; (or) nptr=number;  ARRAY OF POINTER The array of pointers represents a collection of address. by declaring array of pointers we can save a subtantial amount of memory space.  POINTERS AND STRINGS C++ also allows us to handle the special kind of arrays, I e, strings with pointers. we known that a string is one dimensional array of character, which start with the index “0” and end with the null character in C++. Syntax: Int*in array[10] Syntax: char num[]=”one”; Const char *number=”one”;
  • 8.  POINTERS TO FUNCTIONS The pointer to function is known as callback function, we can use these function pointers to refer to a function. using function pointers ,we can allow a C++ program to select a function dynamically at run time. POINTER USING C++: #include<iostream.h> #include<conio.h> Void main( ) { Int a,*ptr1; Ptr1=&a; Cout<<“The address of a:”<<ptr1<<“/n”; Getch( ); } Syntax: data_type(*function_ name);
  • 9. As started earlier ,a pointer can point to an object created by a class item x; when item is and x is an object defined to be of type item. similarly we can define a pointer. Example: class item { Int code;Float price; Public: Void getdata(int a, float b) {Code=a; price=b;} Void show(void) {cout<<“code:”<<code<<“/n”; Cout<<“price:”<<price<<“/n”;} }; item*it_ ptr;
  • 10. Example: #include< iostream. h> #include<conio.h> Class test {private: Int x; Public: Void set x(int x) {this->x=x;} void print(){ cout<<“x=“}; int main() { Test obj; Int x=20; Obj. setx(x); Obj . print(); Return 0;}  This this pointer is a constant pointer that holds the memory address of the current object ,The this pointer is not available in static member functions can be called without any object. static member functions can be called with class name. OUTPUT: X=20
  • 11. All derived classes inherit properties from the common base class. Pointers can be declared to the point base or derived class. pointers to objects of the base class are type compatible with pointers to objects of derived class .A base class pointer can point to objects of both the baseand derived class. B*cptr; //pointer to class b type variable B b; / /base object D d; //derived object Cptr=&b; //cptr points to object b Cptr=&d; //cptr points to object d
  • 12. A virtual function is a member function that you expect to Be refined in derived classes. When you refer to a derived Class objects using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function.
  • 14. Pure virtual function is also known as abstract function. A class with at least one Pure virtual function or abstract function is called abstract class. We can’t create an member function of abstract class will be invoked by derived class object.