SlideShare a Scribd company logo
Author – Subhasis Nayak
   Pointer assignments
   Pointer arithmetic
   Pointer comparisons
   Pointers & arrays
   Arrays of pointers
   Multiple indirection
   Pointers to function
   Dynamic allocations
   We know how to point a variable .
      In this example I will show how to point a
       variable from two pointers.

You must pass the vaddres1
to vAddress2.Because we
passed the address of
variable to vaddress1 not to
vAddress2
   There are only two arithmetic operations that
    you may use on pointers:
    ◦ Addition
    ◦ Subtraction
   But you can do all operation on pointer’s
    value as:
    ◦   Addition
    ◦   Subtraction
    ◦   Multiplication
    ◦   division
   There are two type of comparison of pointers
    ◦ In between pointer = this is the comparison held
      between the addresses they hold

                      If (p1>p2)


    ◦ In between pointer value = here we comparing
      between the values they hold.

                     If (*p1>*p2)
   you can direct a pointer to hold the array's address as
    we do for a normal variable.
   As I told you array is a sequence of similar type of
    data type.
   To hold the array's address when you direct the
    pointer to hold array's address it holds the first’s of
    that array address only.
   To get the address of each element of array we have
    to add the exact index number of that element. how
    can we do that? we can do that with help of a loop or
    directly adding the index’s number.
Int array[5];     Int array[5];
Int *Parray;      Int *Parray;
Parray = array;   Parray = &array[0];
   We already learned array of integers, array of
    floats. As like those we have one type of array i.e.
    Arrays of pointer.
   Arrays of pointer will only hold a bunch of
    addresses.
   These addresses may be addresses of arrays or
    may be addresses of different variables.
   As for a integer type array compiler allocates
    sequence of memory to store hold addresses.
   When we create pointer array we have to
    initialize the each element to direct to a
    address.
   The address may be a address of a variable or
    an array. But they must be similar data type
    of pointer array
                    int var1 = 400,var2 = 600;

                    int *arrpo[2];

                    arrpo[0] = &var1;
                    arrpo[1] = &var2;
   We can say it point to pointer. It means we can
    hold the address of a pointer as we hold the
    address of the variable.
   So when a pointer points to the address of a
    variable we told it indirection. When another
    pointer points to that pointer which points to a
    variable is called multiple indirection.

                     int var;
                     int *fPointer,**spointer;
                     fpointer = &var;
                     spointer = &fpointer;
Pointer02     Pointer01     variable

  • Address     • Address     • Value
   When we have a pointer to a pointer the
    pointer which will point to variable. We will
    confuse with (*), (**) and (&). So do not
    confuse with these.
                                 var = gives value stored in var
    int var;                    *fpointer = gives value stored in var
    int *fPointer,**spointer;   **spointer = gives value stored in var
    fpointer = &var;
    spointer = &fpointer;
                                *spointer = gives address of fpointer
                                &spointer = gives address of spointer
                                &fpointer = gives address of fpointer
                                &var = gives address of variable
   Even though a function is not a variable, it still
    has a physical location in memory that can be
    assigned to a pointer.
   This address is the entry point of the function
    and it is the address used when the function is
    called.
   Once a pointer points to a function, the function
    can be called through that pointer.
   Function pointers also allow functions to be
    passed as arguments to other functions.

More Related Content

What's hot

Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
minal kumar soni
 
Pointer in c++ part3
Pointer in c++ part3Pointer in c++ part3
Pointer in c++ part3
Subhasis Nayak
 
c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)
Ameer Hamxa
 
C pointer
C pointerC pointer
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
C programming - Pointer and DMA
C programming - Pointer and DMAC programming - Pointer and DMA
C programming - Pointer and DMA
Achyut Devkota
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 
pointers
pointerspointers
pointers
teach4uin
 
C Pointers
C PointersC Pointers
C Pointers
omukhtar
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
tanmaymodi4
 
Pointers
PointersPointers
Pointers
Joy Forerver
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Prabhu Govind
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
Uri Dekel
 
8 Pointers
8 Pointers8 Pointers
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 

What's hot (20)

Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
 
Pointer in c++ part3
Pointer in c++ part3Pointer in c++ part3
Pointer in c++ part3
 
c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)c++ pointers by Amir Hamza Khan (SZABISTIAN)
c++ pointers by Amir Hamza Khan (SZABISTIAN)
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
C pointer
C pointerC pointer
C pointer
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
C programming - Pointer and DMA
C programming - Pointer and DMAC programming - Pointer and DMA
C programming - Pointer and DMA
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
pointers
pointerspointers
pointers
 
Ponters
PontersPonters
Ponters
 
Pointer
PointerPointer
Pointer
 
C pointer basics
C pointer basicsC pointer basics
C pointer basics
 
C Pointers
C PointersC Pointers
C Pointers
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Pointers in c v5 12102017 1
Pointers in c v5 12102017 1Pointers in c v5 12102017 1
Pointers in c v5 12102017 1
 
Pointers
PointersPointers
Pointers
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 

Viewers also liked

Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
Sajid Hasan
 
Arrays in C
Arrays in CArrays in C
Arrays in C
Kamruddin Nur
 
Amazon Web Services
Amazon Web ServicesAmazon Web Services
Amazon Web Services
Kamruddin Nur
 
jal hi jivan hai pre prentation
jal hi jivan hai pre prentationjal hi jivan hai pre prentation
jal hi jivan hai pre prentationSatyam Soni
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arrays
Satyam Soni
 
Structures
StructuresStructures
Structures
archikabhatia
 
Array in C
Array in CArray in C
Array in C
Kamal Acharya
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Arrays
ArraysArrays
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 

Viewers also liked (10)

Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
Amazon Web Services
Amazon Web ServicesAmazon Web Services
Amazon Web Services
 
jal hi jivan hai pre prentation
jal hi jivan hai pre prentationjal hi jivan hai pre prentation
jal hi jivan hai pre prentation
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arrays
 
Structures
StructuresStructures
Structures
 
Array in C
Array in CArray in C
Array in C
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Arrays
ArraysArrays
Arrays
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 

Similar to Pointer in c++ part2

POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
SowmyaJyothi3
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
Tanmay Modi
 
Pointer
PointerPointer
Pointers in C
Pointers in CPointers in C
Pointers in C
Monishkanungo
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
nmahi96
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
ArshiniGubbala3
 
Pointer introduction day1
Pointer introduction day1Pointer introduction day1
Pointer introduction day1
Bhuvana Gowtham
 
Pointer in c
Pointer in cPointer in c
Pointer in c
sangrampatil81
 
Pointer in c
Pointer in c Pointer in c
Pointer in c
sangrampatil81
 
Pointers
PointersPointers
Pointers
Prasadu Peddi
 
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
sajinis3
 
SPC Unit 3
SPC Unit 3SPC Unit 3
SPC Unit 3
SIMONTHOMAS S
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
Samsil Arefin
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
AtharvPotdar2
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
janithlakshan1
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
Md. Afif Al Mamun
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptx
sangeeta borde
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
Ramakrishna Reddy Bijjam
 

Similar to Pointer in c++ part2 (20)

POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
 
Lect 8(pointers) Zaheer Abbas
Lect 8(pointers) Zaheer AbbasLect 8(pointers) Zaheer Abbas
Lect 8(pointers) Zaheer Abbas
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
 
Pointer
PointerPointer
Pointer
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
Pointers-Computer programming
Pointers-Computer programmingPointers-Computer programming
Pointers-Computer programming
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Pointer introduction day1
Pointer introduction day1Pointer introduction day1
Pointer introduction day1
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Pointer in c
Pointer in c Pointer in c
Pointer in c
 
Pointers
PointersPointers
Pointers
 
PPS-POINTERS.pptx
PPS-POINTERS.pptxPPS-POINTERS.pptx
PPS-POINTERS.pptx
 
SPC Unit 3
SPC Unit 3SPC Unit 3
SPC Unit 3
 
Data structure lecture 1
Data structure   lecture 1Data structure   lecture 1
Data structure lecture 1
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
 
FYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptxFYBSC(CS)_UNIT-1_Pointers in C.pptx
FYBSC(CS)_UNIT-1_Pointers in C.pptx
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
 

More from Subhasis Nayak

Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
Subhasis Nayak
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql
Subhasis Nayak
 
Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)
Subhasis Nayak
 
Jsp 01
Jsp 01Jsp 01
Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003
Subhasis Nayak
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
Subhasis Nayak
 
Php, mysqlpart2
Php, mysqlpart2Php, mysqlpart2
Php, mysqlpart2
Subhasis Nayak
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
Subhasis Nayak
 
Servlet & jsp
Servlet  &  jspServlet  &  jsp
Servlet & jsp
Subhasis Nayak
 
J2ee connector architecture
J2ee connector architectureJ2ee connector architecture
J2ee connector architecture
Subhasis Nayak
 
how to create object
how to create objecthow to create object
how to create object
Subhasis Nayak
 
C++ arrays part2
C++ arrays part2C++ arrays part2
C++ arrays part2
Subhasis Nayak
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
Subhasis Nayak
 
Introduction to network
Introduction to networkIntroduction to network
Introduction to network
Subhasis Nayak
 
Flow control in c++
Flow control in c++Flow control in c++
Flow control in c++
Subhasis Nayak
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
Text mode Linux Installation Part 01
Text mode Linux Installation Part 01Text mode Linux Installation Part 01
Text mode Linux Installation Part 01
Subhasis Nayak
 

More from Subhasis Nayak (18)

Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql
 
Php, mysq lpart3
Php, mysq lpart3Php, mysq lpart3
Php, mysq lpart3
 
Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)
 
Jsp 01
Jsp 01Jsp 01
Jsp 01
 
Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
 
Php, mysqlpart2
Php, mysqlpart2Php, mysqlpart2
Php, mysqlpart2
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 
Servlet & jsp
Servlet  &  jspServlet  &  jsp
Servlet & jsp
 
J2ee connector architecture
J2ee connector architectureJ2ee connector architecture
J2ee connector architecture
 
how to create object
how to create objecthow to create object
how to create object
 
C++ arrays part2
C++ arrays part2C++ arrays part2
C++ arrays part2
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
 
Introduction to network
Introduction to networkIntroduction to network
Introduction to network
 
Flow control in c++
Flow control in c++Flow control in c++
Flow control in c++
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
 
Text mode Linux Installation Part 01
Text mode Linux Installation Part 01Text mode Linux Installation Part 01
Text mode Linux Installation Part 01
 

Recently uploaded

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

Pointer in c++ part2

  • 2. Pointer assignments  Pointer arithmetic  Pointer comparisons  Pointers & arrays  Arrays of pointers  Multiple indirection  Pointers to function  Dynamic allocations
  • 3. We know how to point a variable .  In this example I will show how to point a variable from two pointers. You must pass the vaddres1 to vAddress2.Because we passed the address of variable to vaddress1 not to vAddress2
  • 4. There are only two arithmetic operations that you may use on pointers: ◦ Addition ◦ Subtraction  But you can do all operation on pointer’s value as: ◦ Addition ◦ Subtraction ◦ Multiplication ◦ division
  • 5. There are two type of comparison of pointers ◦ In between pointer = this is the comparison held between the addresses they hold If (p1>p2) ◦ In between pointer value = here we comparing between the values they hold. If (*p1>*p2)
  • 6.
  • 7.
  • 8. you can direct a pointer to hold the array's address as we do for a normal variable.  As I told you array is a sequence of similar type of data type.  To hold the array's address when you direct the pointer to hold array's address it holds the first’s of that array address only.  To get the address of each element of array we have to add the exact index number of that element. how can we do that? we can do that with help of a loop or directly adding the index’s number.
  • 9. Int array[5]; Int array[5]; Int *Parray; Int *Parray; Parray = array; Parray = &array[0];
  • 10.
  • 11.
  • 12.
  • 13. We already learned array of integers, array of floats. As like those we have one type of array i.e. Arrays of pointer.  Arrays of pointer will only hold a bunch of addresses.  These addresses may be addresses of arrays or may be addresses of different variables.  As for a integer type array compiler allocates sequence of memory to store hold addresses.
  • 14. When we create pointer array we have to initialize the each element to direct to a address.  The address may be a address of a variable or an array. But they must be similar data type of pointer array int var1 = 400,var2 = 600; int *arrpo[2]; arrpo[0] = &var1; arrpo[1] = &var2;
  • 15.
  • 16.
  • 17. We can say it point to pointer. It means we can hold the address of a pointer as we hold the address of the variable.  So when a pointer points to the address of a variable we told it indirection. When another pointer points to that pointer which points to a variable is called multiple indirection. int var; int *fPointer,**spointer; fpointer = &var; spointer = &fpointer;
  • 18. Pointer02 Pointer01 variable • Address • Address • Value
  • 19. When we have a pointer to a pointer the pointer which will point to variable. We will confuse with (*), (**) and (&). So do not confuse with these.  var = gives value stored in var int var; *fpointer = gives value stored in var int *fPointer,**spointer; **spointer = gives value stored in var fpointer = &var; spointer = &fpointer; *spointer = gives address of fpointer &spointer = gives address of spointer &fpointer = gives address of fpointer &var = gives address of variable
  • 20.
  • 21. Even though a function is not a variable, it still has a physical location in memory that can be assigned to a pointer.  This address is the entry point of the function and it is the address used when the function is called.  Once a pointer points to a function, the function can be called through that pointer.  Function pointers also allow functions to be passed as arguments to other functions.