Copy Semantics Flashcards
What does the const keyword in C mean?
A way to declare that a variable’s value will not change.
What does the const keyword mean for a function parameter?
That the function will not change a value.
Convert this declaration to a sentence:
char * str[10];
str is an array 10 of pointers to a char.
Convert this declaration to a sentence:
int * a;
a is a pointer to an int
Convert this declaration to a sentence:
const int * b;
b is a pointer to an int constant
Convert this declaration to a sentence:
int * const c;
c is a constant pointer to an int
Convert this declaration to a sentence:
const int * const d
d is a constant pointer to an int constant
What happens when you try to free freed memory on the heap?
Segmentation fault
What can shallow copying lead to?
Memory leaks
What is a shallow copy?
When you store the instance of the desired value instead of the copied values themselves.