diff --git a/lectures/04_pointers/README.md b/lectures/04_pointers/README.md index 6049f86..e519492 100644 --- a/lectures/04_pointers/README.md +++ b/lectures/04_pointers/README.md @@ -112,15 +112,15 @@ cout << x << " " << y << endl; - Like the int type, pointers are not default initialized. We should assume it’s a garbage value, leftover from the previous user of that memory. -- Pointers that don’t (yet) point anywhere useful are often explicitly assigned to NULL. - – NULL is equal to the integer 0, which is a legal pointer value (you can store NULL in a pointer variable). - – But NULL is not a valid memory location you are allowed to read or write. If you try to dereference or +- Pointers that don’t (yet) point anywhere useful are often explicitly assigned to NULL. + - NULL is equal to the integer 0, which is a legal pointer value (you can store NULL in a pointer variable). + - But NULL is not a valid memory location you are allowed to read or write. If you try to dereference or follow a NULL pointer, your program will immediately crash. You may see a segmentation fault, a bus error, or something about a null pointer dereference. - – NOTE: In C++11, we are encouraged to switch to use **nullptr** instead of NULL or 0, to avoid some + - NOTE: In C++11, we are encouraged to switch to use **nullptr** instead of NULL or 0, to avoid some subtle situations where NULL is incorrectly seen as an int type instead of a pointer. For this course we will assume NULL and nullptr are equivalent. - – We indicate a NULL or nullptr value in diagrams with a slash through the memory location box. + - We indicate a NULL or nullptr value in diagrams with a slash through the memory location box. - Comparing a pointer to NULL is very useful. It can be used to indicate whether or not a pointer variable is pointing at a useable memory location. For example, ```cpp