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

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

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