SlideShare una empresa de Scribd logo
1 de 9
Lecture 7
ChaaND Sheikh
Pointers.
//Demonstration.
#include<conio.h>
Every Block is
#include<iostream.h>
a memory cell
void main()
{
Cell no’s / Address
int x ;
float y;
x = 10;

Memory
4001

4002

4003

4004

4005

4006

4007

4008

4009

10

x
y

4007
y = 20.0;

}

cout<<“Value’s of x and y = “<<x<<y;
getch();
4007

20.0

4002
• Pointers deals with memory address, using pointers we
can access memory directly. storing pointer type entity
we need special type variables.
•

data-type * Variable_name;
Type of data
stored in the
address of
the variable.

Indirection
operator
&

*

Address of (Reference) Operator.
Value At Address (Indirection) operator.

void main()
20.0
Value at Address.
{
int *int_ptr;
10
float *float_ptr;
Address
4002
4007
int x = 10 ;
x
y
Name od address
float y = 20.0;
cout<<“Value’s of x and y = “<<x<<“ “<<y;
int_ptr = &x;
float_ptr = &y;
cout<<"int_ptr = "<<int_ptr;
cout<<"n float_ptr = "<<float_ptr;
cout<<"n value in int_pointer = "<< *int_ptr;
cout<<"n value in float_ptr = "<< *float_ptr;
getch(); }
&

Address of (Reference) Operator.

*

Value At Address (Indirection) operator.

// Demonstration.
#include <iostream.h>
#include<conio.h>
void main ()
{
int variable ;
int *mypointer;
mypointer = &variable;
*mypointer = 50;

50
3722
variable

Address of variable = mypointer
50 = value at address

cout << "value in variable is " <<variable<<endl;
getch();
}
Value in variable is 50
//Demonstration
& Address of (Reference) Operator.
#include <iostream.h>
* Value At Address (Indirection) operator.
#include<conio.h>
main ()
{
10
5888
2554
int x=10;
int *y;
2554
5888
6550
int **z;
**z
x
*y
cout<<"Value of x = "<<x;
cout<<"nAdd of x = "<<&x;
Value of x = 10
cout<<"nValue of x = "<<*(&x);
Add of x = 2554
y=&x;
cout<<"nAdd of y = "<<&y;
Value of x = 10
cout<<"nAdd in y = "<<y;
Add of y = 5888
z=&y;
cout<<"nAdd of z = "<<&z;
Add in y = 2554
cout<<"nAdd in z = "<<z;
getch();
Add of y = 6550
}
Add in z = 5888
//Demonstration

& Address of (Reference) Operator.

#include <iostream.h>
* Value At Address (Indirection) operator.
#include<conio.h>
main ()
{
10
5888
2554
int x=10;
2554
5888
6550
int *y;
**z
x
*y
int **z;
cout<<"Value of x = "<<x;
cout<<"nAdd of x = "<<&x;
Value of x = 10
y=&x;
Add of x = 2554
cout<<“Accessing x via ptr y = ”<<*y;
z=&y;
x via prt y = 10
cout<<“Accessing x via ptr z ”<<**z;
x via prt z = 10
getch();
}
&

Address of (Reference) Operator.

*

Value At Address (Indirection) operator.

1. *& variable = variable
2. *(&)variable = *&variable
Example 1 :
int x =10;
cout<<*&x;
10
cout<<*(&)x;
Example 2 :
int x = 10;
int * p;
p = &x;
cout<<* p;

10

Más contenido relacionado

La actualidad más candente

Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++NUST Stuff
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...ssuserd6b1fd
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer웅식 전
 
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-13Abu Saleh
 
C++ Function
C++ FunctionC++ Function
C++ FunctionHajar
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2rohassanie
 
Arrry structure Stacks in data structure
Arrry structure Stacks  in data structureArrry structure Stacks  in data structure
Arrry structure Stacks in data structurelodhran-hayat
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Dharma Kshetri
 

La actualidad más candente (20)

Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++
 
This pointer
This pointerThis pointer
This pointer
 
Pointers+(2)
Pointers+(2)Pointers+(2)
Pointers+(2)
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
C++ programming function
C++ programming functionC++ programming function
C++ programming function
 
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer
 
Arrays
ArraysArrays
Arrays
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
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
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2FP 201 - Unit4 Part 2
FP 201 - Unit4 Part 2
 
Arrry structure Stacks in data structure
Arrry structure Stacks  in data structureArrry structure Stacks  in data structure
Arrry structure Stacks in data structure
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
pointers
pointerspointers
pointers
 

Destacado (20)

Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Pointers
PointersPointers
Pointers
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
C Pointers
C PointersC Pointers
C Pointers
 
Ponters
PontersPonters
Ponters
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
intro to pointer C++
intro to  pointer C++intro to  pointer C++
intro to pointer C++
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
 
C pointer basics
C pointer basicsC pointer basics
C pointer basics
 
C pointer
C pointerC pointer
C pointer
 
C++ classes
C++ classesC++ classes
C++ classes
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
 
Pointers & References in C++
Pointers & References in C++Pointers & References in C++
Pointers & References in C++
 
This pointer .17
This pointer .17This pointer .17
This pointer .17
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 

Similar a C++ Pointers

Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2Mouna Guru
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Abdul Samee
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Fwdays
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Datagreenwop
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxdewhirstichabod
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
 

Similar a C++ Pointers (20)

Pointers
PointersPointers
Pointers
 
Unit 3
Unit 3Unit 3
Unit 3
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Pointer
PointerPointer
Pointer
 
Oops lab manual2
Oops lab manual2Oops lab manual2
Oops lab manual2
 
C++ examples &revisions
C++ examples &revisionsC++ examples &revisions
C++ examples &revisions
 
Pointers
PointersPointers
Pointers
 
P1
P1P1
P1
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"Max Koretskyi "Why are Angular and React so fast?"
Max Koretskyi "Why are Angular and React so fast?"
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docx
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
C++ L05-Functions
C++ L05-FunctionsC++ L05-Functions
C++ L05-Functions
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
Pointers
PointersPointers
Pointers
 

Último

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

C++ Pointers

  • 3. //Demonstration. #include<conio.h> Every Block is #include<iostream.h> a memory cell void main() { Cell no’s / Address int x ; float y; x = 10; Memory 4001 4002 4003 4004 4005 4006 4007 4008 4009 10 x y 4007 y = 20.0; } cout<<“Value’s of x and y = “<<x<<y; getch(); 4007 20.0 4002
  • 4. • Pointers deals with memory address, using pointers we can access memory directly. storing pointer type entity we need special type variables. • data-type * Variable_name; Type of data stored in the address of the variable. Indirection operator
  • 5. & * Address of (Reference) Operator. Value At Address (Indirection) operator. void main() 20.0 Value at Address. { int *int_ptr; 10 float *float_ptr; Address 4002 4007 int x = 10 ; x y Name od address float y = 20.0; cout<<“Value’s of x and y = “<<x<<“ “<<y; int_ptr = &x; float_ptr = &y; cout<<"int_ptr = "<<int_ptr; cout<<"n float_ptr = "<<float_ptr; cout<<"n value in int_pointer = "<< *int_ptr; cout<<"n value in float_ptr = "<< *float_ptr; getch(); }
  • 6. & Address of (Reference) Operator. * Value At Address (Indirection) operator. // Demonstration. #include <iostream.h> #include<conio.h> void main () { int variable ; int *mypointer; mypointer = &variable; *mypointer = 50; 50 3722 variable Address of variable = mypointer 50 = value at address cout << "value in variable is " <<variable<<endl; getch(); } Value in variable is 50
  • 7. //Demonstration & Address of (Reference) Operator. #include <iostream.h> * Value At Address (Indirection) operator. #include<conio.h> main () { 10 5888 2554 int x=10; int *y; 2554 5888 6550 int **z; **z x *y cout<<"Value of x = "<<x; cout<<"nAdd of x = "<<&x; Value of x = 10 cout<<"nValue of x = "<<*(&x); Add of x = 2554 y=&x; cout<<"nAdd of y = "<<&y; Value of x = 10 cout<<"nAdd in y = "<<y; Add of y = 5888 z=&y; cout<<"nAdd of z = "<<&z; Add in y = 2554 cout<<"nAdd in z = "<<z; getch(); Add of y = 6550 } Add in z = 5888
  • 8. //Demonstration & Address of (Reference) Operator. #include <iostream.h> * Value At Address (Indirection) operator. #include<conio.h> main () { 10 5888 2554 int x=10; 2554 5888 6550 int *y; **z x *y int **z; cout<<"Value of x = "<<x; cout<<"nAdd of x = "<<&x; Value of x = 10 y=&x; Add of x = 2554 cout<<“Accessing x via ptr y = ”<<*y; z=&y; x via prt y = 10 cout<<“Accessing x via ptr z ”<<**z; x via prt z = 10 getch(); }
  • 9. & Address of (Reference) Operator. * Value At Address (Indirection) operator. 1. *& variable = variable 2. *(&)variable = *&variable Example 1 : int x =10; cout<<*&x; 10 cout<<*(&)x; Example 2 : int x = 10; int * p; p = &x; cout<<* p; 10