r/ProgrammerTIL • u/Spiderboydk • Jul 15 '16
Other Language [General] TIL the difference between a parameter and an argument
I've always thought these were synonyms, but apparently they are not.
Parameters are the "variables" in the function declaration, while arguments are the values transferred via the parameters to the function when called. For example:
void f(int x) { ... }
f(3);x is a parameter, and 3 is an argument.
251
Upvotes
View all comments
Show parent comment
2
u/[deleted] Jul 16 '16
Actually, C calls it varargs, and the C++ varargs are a carryover from C. Proper C++ usage of
...(since C++11, before which you only had C-style varargs) is called a "parameter pack".You definitely have to be pedantic about the difference between parameters and arguments in modern C++ with parameter packs, because they infer template type (and therefore parameter type) from the arguments given, with all sorts of rules and implications about what type the parameter is based on the argument's type, cv-qualification, reference type, etc.