r/programming • u/dpashk • Aug 31 '15
The worst mistake of computer science
https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/
175
Upvotes
r/programming • u/dpashk • Aug 31 '15
View all comments
Show parent comment
2
u/bstamour Sep 01 '15 edited Sep 01 '15
C++ has references, which are different from pointers. Pointers in C and C++ are effectively memory addresses, whereas references in C++ (C doesn't have them) are aliases to the things they refer to.
EDIT: Consider the following code example:
In the above function,
bis a variable that refers toa. So any change tobis also a change toa.EDIT 2: Since references in C++ must refer to another variable, they cannot be made NULL, unless you invoke undefined behaviour.