Pointers Flashcards

1
Q

What do pointers do in C++

A

They point to a location in memory

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

What is the & character

A

The reference character; a variable with a leading & provides the memory address of that variable

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

How do you create a pointer?

A

type* var, or type var.
ex: int
one, int *two

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

How do you assign stack memory to a pointer?

A

int target = 7;
int *point =⌖

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

How is the * character used to dereference?

A

When put in front of a pointer, it will provide the value in that memory address.

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

How is pointer math performed assuming same pointer type?

A

The pointers will perform arithmatic in the units of the type.
ex: int *one - int *two = 1, assuming they were declared one after the other.

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

Given array y, what does *y return?

A

The memory address of the first index.

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

What is created with int *a;?

A

Movable pointer to writable int

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

What is created with const int *b;?

A

Movable pointer to read-only int

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

What is created with int *const c;?

A

unmoveable pointer writable int.

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

What is created with const int *const d;?

A

unmovable pointer to read-only int.

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

What is created with int &e = …;?

A

read/write reference an int

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

What is created with const int &f = …;?

A

read only reference

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

How do you use allocated memory with a pointer?

A

With the ‘new’ keyword.

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

What are the 2 keyword pairs to remember for heap memory allocation?

A

new/delete and new[]/delete[]

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

What type of memory is on the heap?

A

Dynamic Memory

17
Q

How do you get access to the typeid function?

A

include <typeinfo></typeinfo>

18
Q

What does typeid return?

A

A type_info object.

19
Q

What is useful about type_info objects?

A

They are comparable.