06 October 2013

Parameters and Arguments

Parameters are the things when you define the function. Arguments are the things when you call the function.

int f(int x) { return x + 1; } // x is parameter
int main() { cout << f(2 + 3); } // 2 + 3 is argument
Terrible mnemonic:
  • Parameters have parallel structure --- just [type name] [var name] or some variant thereof, nothing fancy.
  • Arguments can include arithmetic operations, or any other kind of operations.
  • Parameters are part of the function definition.
  • Arguments are what actually arrive inside the function.

The only reason I'm remembering this is to be technically correct ("the best kind of correct!")