Copy Semantics Flashcards

1
Q

What does the const keyword in C mean?

A

A way to declare that a variable’s value will not change.

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

What does the const keyword mean for a function parameter?

A

That the function will not change a value.

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

Convert this declaration to a sentence:
char * str[10];

A

str is an array 10 of pointers to a char.

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

Convert this declaration to a sentence:
int * a;

A

a is a pointer to an int

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

Convert this declaration to a sentence:
const int * b;

A

b is a pointer to an int constant

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

Convert this declaration to a sentence:
int * const c;

A

c is a constant pointer to an int

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

Convert this declaration to a sentence:
const int * const d

A

d is a constant pointer to an int constant

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

What happens when you try to free freed memory on the heap?

A

Segmentation fault

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

What can shallow copying lead to?

A

Memory leaks

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

What is a shallow copy?

A

When you store the instance of the desired value instead of the copied values themselves.

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