I’m reading some sections of “The C Programming Language” by Kernighan and Ritchie. In the pointers section, the authors state:
“The syntax of the declaration for a variable mimics the syntax of expressions in which the variable might appear.”
I believe this principle is similar to the “Declaration Reflects Use” rule often discussed in C and C++ programming.
However, when I started learning about reference variables in C++, I found it difficult to apply this rule. For instance: int& ref = x;
The use of ref doesn’t require the & symbol, unlike its declaration.
deviated from this principle for references?
so My questions are:
Is the statement from K&R the same as the “Declaration Reflects Use” rule?
Does this rule apply to C++ reference variables? If so, how?
If it doesn’t apply, why might C++ have