Pointers
By Sarah Gates
Starter Task
•
Short Discussion:
–
Emison
–
Pointers
–
Glenn
–
Hexadecimal numbers
•
What do you remember about them?
•
What was the defining points you remember
from those sessions?
Learning Objectives
•
Know the 2 different types of data structure
(Dynamic and Static)
•
Know what a pointer is in Programming and
where they are used.
•
Identify different types of pointers, and
understand why these different types are
needed.
First things first…
•
Data structure
–
A collection of data stored in memory, plus a number of
operations included by the software to manipulate the
data structure (Definition found on Teach ICT website
http://www.teach
-
ict.com/as_as_computing/ocr/H447/F453/3_3_5/dat
a_structures/miniweb/pg2.htm
)
•
Different types of Data structure
–
Dynamic (Stack) Where memory is allocated at the point
of run time.
–
Static (List) memory is allocated at the time the
structure is compiled and is fixed.
Pointers
•
Sometimes called “references” (e.g. in Perl…)
•
A variable which “points” to a location in the
memory of a computer.
–
Usually points to an address (numbered location of a
place in the memory),
–
Used in almost all programming languages including C,
C++, Pascal, Perl, and BASIC.
•
Different types of pointers
–
Managed
–
Unmanaged function pointers
–
Stack
An example
Cont
•
Address locations given in Hexadecimal
numbers
–
int
*
hardware_address
= (
int
*)0x7FFF;
–
an example of a pointer initialising to a
hexidecimal
address.
•
http://www.youtube.com/watch?v=f
-
pJlnpkLp0
•
A fun little video about pointers and
pointees
Finally: taken from
http://xkcd.com/138/
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο