L19pointers

L19pointers - Pointers What is Pointer q q q q q every...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Pointers
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is Pointer every variable has memory address char c=‘y’; int i=2; address of variable i is 0022 address can used to refer to this variable address can be stored in a variable of special type called pointer (variable) C++ provides an abstraction of pointer pointer is used only to refer to the variable it points to - we usually don’t think of pointers as holding integer (address) just a reference to a variable name memory address i ‘y’ c 2 0021 0022 0021 cp name memory address i ‘y’ c 2 0021 0022 cp
Background image of page 2
Pointer Syntax pointer variable is declared as follows: type_of_variable_pointed_to *pointer_name; example: double *p; int *ip; pointer declarations can be freely intermixed with ordinary variable declarations: char *cp, c1=‘y’, c2=‘n’; int i, *ip,; pointer to a pointer is legal and sometimes used: char **cpp; address of ) operator: cp = &c1; // until reassigned cp “points at” c
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

L19pointers - Pointers What is Pointer q q q q q every...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online