Difference between parameter and argument reproduced from: http://smilejay.com/2011/11/parameter_argument/
When I write a comment on a function, I am considering whether to use parameter or argument to describe its parameters.
According to some information on the Internet, the difference between parameter and argument is briefly described as follows.
1. Parameter refers to the parameter in the function definition, while argument refers to the actual parameter during function calling.
2. A brief description is as follows: parameter = parameter (formal parameter), argument = real parameter (actual parameter ).
3. In the not strict circumstances, the two can now be mixed, generally use argument, while parameter is less used.
While defining method, variables passed in the method are called parameters.
When defining a method, the variables passed to the method are called parameters.
While using those methods, values passed to those variables are called arguments.
When a method is called, the value passed to the variable is called a reference. (sometimes argument is translated as a reference.)
A c ++ example shows the differences between the two:
[Copy to clipboard] view code CPP
123456789101112 |
void func(int n, char * pc); //n and pc are parameterstemplate <class T> A {}; //T is a a parameter int main(){ char c; char *p = &c; func(5, p); //5 and p are arguments A<long> a; //'long' is an argument A<char> another_a; //'char' is an argument return 0;} |
The following is a description from Wikipedia:
Http://en.wikipedia.org/wiki/Parameter_%28computer_programming%29
Just as in standard mathematical usage, the argument is thus the actual value passed to a function, procedure, or routine (such as X in log x ), whereas the parameter is a reference to that value inside the implementation of the function (log in this case ).
See the parameters and arguments section for more information.
Parameters and arguments
----------------
These two terms are sometimes loosely used interchangeably; in particle, "argument" is sometimes used in place of "parameter ". nevertheless, there is a difference. properly, parameters appear in procedure definitions; arguments appear in procedure CILS.
A parameter is an intrinsic property of the procedure, encoded ded in its definition. for example, in rule versions, a minimal procedure to add two supplied integers together and calculate the sum total wowould need two parameters, one for each expected integer.
In general, a procedure may be defined with any number of parameters, or no parameters at all. if a procedure has parameters, the part of its definition that specifies the parameters is called its parameter list.
By contrast, the arguments are the values actually supplied to the procedure when it is called. unlike the parameters, which form an unchanging part of the procedure's definition, the arguments can, and often do, vary from call to call. each time a procedure
Is called, the part of the procedure call that specifies the arguments is called the argument list.
Although parameters are also commonly referred to as arguments, arguments are more properly thought of as the actual values or references assigned to the parameter variables when the subroutine is called at run-time. when discussing code that is calling
Into a subroutine, any values or references passed into the subroutine are the arguments, and the place in the Code where these values or references are given is the parameter list. when discussing the code inside the subroutine definition, the variables in
The subroutine's parameter list are the parameters, while the values of the parameters at runtime are the arguments.
Extends programmers use parameter and argument interchangeably, depending on context to distinguish the meaning. the term formal parameter refers to the variable as found in the function definition (parameter), while actual parameter refers to the actual value
Passed (argument ).