The difference between a formal parameter and an argument

Source: Internet
Author: User



The formal parameter appears in the function definition and can be used throughout the body of the function, leaving the function unused.
The argument appears in the keynote function, and when it enters the function, the real parametric is not used .
The keynote function transmits the value of the argument to the parameter of the modulated function, thus realizing the transfer of the keynote function to the transferred function .
1. Parametric the memory unit is allocated only when called, releasing the allocated memory unit immediately at the end of the call . Therefore, the formal parameter is valid only within the function. The parameter variable can no longer be used when the function call finishes returning the keynote function.
2. Arguments can be constants, variables, expressions, functions, and so on, regardless of the type of argument, and when making a function call, they must have a definite value in order to pass these values to the parameter. Therefore, an assignment, input, and so on should be used to obtain a definite value for the argument.
4. The data transfer that occurs in a function call is one-way . That is, the value of the argument can only be passed to the parameter, and the value of the parameter cannot be passed to the argument in reverse. Therefore, during a function call, the value of the formal parameter changes, and the value in the argument does not change.
5. When a formal parameter and an argument are not pointer types, when the function is run, the formal parameters and arguments are different variables, they are in different locations in memory, the contents of the arguments arguments are copied, and the parameters are freed at the end of the function's run, and the argument content does not change . and if the function's argument is a pointer-type variable, in the process of invoking the function, the address of the argument to the function, which is used inside the function body is also the address of the argument, that is, the argument itself is used . Therefore, the value of the argument can be changed inside the function body.


The simple point is actually


The argument is the value after the formal parameter is assigned, and it is useful to participate in the actual operation.

The difference between a formal parameter and an argument

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.