Differences
| POINTER | REFERENCE |
|---|---|
| Is a variable that holds memory address of another variable. // int *ptr = &i; | Is an alias i.e. another name for an already existing variable. // int &ref = i; |
| Can point nowhere e.g. NULL | Must refer to an object |
| Can be re-assigned any number of times | Cannot be re-assigned after binding |
| Can take the address of a pointer | Can’t take the address of a reference |
Leave a comment