3 ms·
The key distinction is not variable vs function argument, but rather const variable vs pointer-to-const. If you have "const int x" (as a local variable, global
by haberman 10y ago
The key distinction is not variable vs function argument, but rather const variable vs pointer-to-const.
If you have "const int x" (as a local variable, global variable, or function parameter) then there is no valid way to modify x's value. But if you have "const int* y" (as a local variable, global variable, or function parameter), you can always cast away const and mutate as long as the original variable (the one "y" points to) wasn't declared const.