lecture 9: pointers Flashcards

(27 cards)

1
Q

what is memory?

A

a list of sequential locations known as words

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

can you access less than a word in modern computers?

A

no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the size of a word today?

A

64 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how many bits are in a byte?

A

8 bits = 1 byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

in memory, what is an int?

A

it is one word in size, 63 bits for the number and 1 bit for the sign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

in memory, what is a char?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

can memory be allocated in blocks?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

in memory, what is int[10]?

A

an array of ten integers, it is assigned ten consecutive words in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

in memory, what is char[10]?

A

an array of ten chars, it is assigned ten consecutive bytes in memory, so two words allocated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

in memory, what is a class that has four ints?

A

the four ints are four consecutive words in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

in memory, what is int *pointer?

A

one word no matter the type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

decimal is base ______

A

10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

hex is base _______`

A

16 (0 1 2 3 4 5 6 7 8 9 A B C D E F)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

binary is base ________

A

2 (0 1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is &?

A

address - of (reference) operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is *?

A

dereference operator

17
Q

reference variables are actually _________

A

pointers with syntactic sugar

18
Q

can you return a reference?

A

yes, but you have to be careful

19
Q

can you return local variables by reference?

20
Q

can you return pointers to local variables?

21
Q

what is allocated in the program block during compile time?

A

normal variables and objects

22
Q

at compile time, the memory for a given ______ can be calculated

23
Q

the variables and objects in the program block are said to be __________

A

statically allocated

24
Q

where is dynamic memory allocated?

A

on the heap (also called system)

25
what does the new operator do?
allocate memory on the heap
26
what does the delete operator do?
deallocate (release) memory on the heap
27
trying to deallocate null does what?
gives an error