Difference between argument and Parameter

Source: Internet
Author: User

I always think that argument and parameter refer to the same thing. However, recently, some documents have mentioned argument and parameter, which obviously have different meanings. Google, it's really different. Now the result is pasted below to make a memo.

1. ANSI/iso c ++ professional programmer's Handbook
The words arguments and parameters are often used interchangeably in the literature, although the standard makes a clear distinction between the two. The distinction is chiefly important when discussing functions and templates.
Argument
An argument is one of the following: an expression in the comma-separated list that is bound by the parentheses in a function call; A sequence of one or more Preprocessor tokens in the comma-separated list that is bound by the parentheses in a function-like
Macro invocation; the operand of a throw-statement or an expression, type, or template-name in the comma-separated list that is bound by the angle brackets in a template instantiation. an argument is also called an actual parameter.
Parameter
A parameter is one of the following: an object or reference that is declared in a function declaration or definition (or in the catch clause of an exception handler ); an identifier from the comma-separated list that is bound by the parentheses immediately following
The macro name in a definition of a function-like macro; or a template-parameter. A parameter is also called a formal parameter.
The following example demonstrates the difference between a parameter and an argument:

void func(int n, char * pc); //n and pc are parameters template <class T> class 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; } 

2. Wikipedia (http://en.wikipedia.org/wiki/Parameter_%28computer_programming%29)
These two terms are sometimes loosely used interchangeably; in particle, "argument" is sometimes used in place of "parameter ". nevertheless, there is a difference. parameters appear in procedure definitions; arguments appear in procedure CILS. loosely,
Parameter is a type, and an argument is an instance.
A parameter is an intrinsic property of the procedure, encoded ded in its definition. for example, in processing ages, a procedure to add two supplied integers together and calculate the sum wowould need two parameters, one for each 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 supplied to the procedure when it is called. unlike the parameters, which form an unchanging part of the procedure's definition, the arguments may vary from call to call. each time a procedure is called, the part
The procedure call that specifies the arguments is called the argument list.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.