Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What are formal parameters and real parameters? What are the ways to pass parameters?
What are formal parameters and real parameters? What are the ways to pass parameters?
Functions in comparative mathematics, such as f(x)

=

2x

+

10

F(x) is the return value and x is the formal parameter. When you assign a value of 5 to X, the real parameter is 5, and when the value is 10, the real parameter is 10.

Therefore, in short, the argument is the assignment of formal parameters when calling a function.

There is essentially only one way to pass parameters, that is, to pass values.

Address delivery and reference delivery are both conceptual transformations of value delivery, such as

empty

calc(int

*

ptr);

When it is called, it appears to be an address, but for the formal parameter ptr, its value is initialized as an argument, so it is a value.

The most essential way to understand it is that from the memory point of view, assigning a value to a variable is nothing more than writing a value somewhere in the memory, so you need to pay attention to whether the target memory has been changed. For example, when writing a value to the memory pointed by the pointer parameter, it is written to the memory pointed by the actual parameter, which is the essence of address transfer.