lecture 9: pointers Flashcards
(27 cards)
what is memory?
a list of sequential locations known as words
can you access less than a word in modern computers?
no
what is the size of a word today?
64 bits
how many bits are in a byte?
8 bits = 1 byte
in memory, what is an int?
it is one word in size, 63 bits for the number and 1 bit for the sign
in memory, what is a char?
it is one byte, but a whole word is assigned to it and that is what you can address (can’t address less than a word in modern architecture)
can memory be allocated in blocks?
yes
in memory, what is int[10]?
an array of ten integers, it is assigned ten consecutive words in memory
in memory, what is char[10]?
an array of ten chars, it is assigned ten consecutive bytes in memory, so two words allocated
in memory, what is a class that has four ints?
the four ints are four consecutive words in memory
in memory, what is int *pointer?
one word no matter the type
decimal is base ______
10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
hex is base _______`
16 (0 1 2 3 4 5 6 7 8 9 A B C D E F)
binary is base ________
2 (0 1)
what is &?
address - of (reference) operator
what is *?
dereference operator
reference variables are actually _________
pointers with syntactic sugar
can you return a reference?
yes, but you have to be careful
can you return local variables by reference?
no
can you return pointers to local variables?
no
what is allocated in the program block during compile time?
normal variables and objects
at compile time, the memory for a given ______ can be calculated
object
the variables and objects in the program block are said to be __________
statically allocated
where is dynamic memory allocated?
on the heap (also called system)