C++ - Reference variables
in the Thinking in C++ (p. 151)
"Pointers work roughly the same in C and in C++, but C++ adds an additional way to pass an address into a function. This is pass-by-reference and it exists in several other programming languages so it was not a C++ invention."
int a = 0;
int &ref = a;
https://www.learncpp.com/cpp-tutorial/611-references/
Pointer vs. Reference
1. Pointers are a superset, references are a subset.
2. References must be initialized when created.
3. References can not be reassigned.
Monday, December 30, 2019
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment