Simply put, it is two words, efficiency.
As we all know, in C function calls, parameters are passed by value, which means that a copy is generated for the real parameter during function calls, and then the function operates on this copy, that is,
Struct variables are used as function parameters and return values.
Prepare to learn opencv, but the syntax of the first knowledge point is not understood: Typedef struct cvpoint {int X;/* x coordinate, usually based on 0 */INT y;/* Y
This paper mainly introduces the function parameters of Python, the parameters of various forms. It is recommended that you try it and deepen your understanding.function parametersWhen defining a function, we determine the name and position of the
JS default is not support funtion f($a=a){} this way of writing, if you want to set the default value of function parameters, you can refer to the following three ways:
The first method:
With arguments, all parameters of the function
function calls:• Pass data to formal parameters with real parameters;• Allocate storage space for data parameters and variables declared in the function body;• Interrupt the current (call) function, and move the process to the entrance of the called
1, parameters into the stack sequence
The order of the function arguments is based on the compiler implementation,
So how does the order of the function parameters in the stack be determined?
2. Calling convention
When a function call
1 Python's function pass:First, all variables can be understood as a ' reference ' to an object in memorya = 1 def Func (a): a = 2 func (a) print (a) # 1 a = 1 def Fun (a): print (" function ", id (a)) # function 41322472 a = 2 print
1. Position parameters: General Parameters2. Default parameters:1 def Power (x, n=2):2 s = 13while n > 0:4 n = n-15 s = S * x6 return sThere is a default assignment in the parameter, and the Power (5) is the square when
The function is to combine a bunch of statements together to form a part:
1. Maximum code reuse, minimal code redundancy2. Process decomposition, function is about the process, tell you how to do things
Parameter description for
Tag: Call to pass a UNC type print return based on the pass Python parameterFive forms of function parameter passing1. Position transferOne-to-one correspondence of formal parameters and argumentsdef Fun (a,b,c) return a+b+CF (All-you-do)2. Keyword
Open (file, mode= ' R ', Buffering=-1, Encoding=none, Errors=none, Newline=none, Closefd=true, Opener=none):In the use of this function, in addition to the file parameter must be filled out, other parameters can be selected. The default values are
Position parameter/position parameter
Default parametersThe default parameter must point to an immutable object, especially when an empty list is used as a function parameter.def f (L = None) PassInstead ofdef f (L = []) Pass
Variable
In the shell, arguments can be passed to a function when it is called. Inside the function body, the value of the parameter is obtained in the form of a $n, for example, $ $ for the first argument, and $ = for the second argument ...Examples of
#-*-coding:utf-8-*-#definition of default parametersdefTest (a,b=10): Print(A +b)#The default parameter must be defined at the end of the parameter list and cannot be defined before the normal parameter#def Test (A,B=10,C)---this way of
First, the definition of the function format:def function name (parameter list):function bodyDef fun1 (A, B, c): return a + B + CSecond, position transfer: Position correspondencePrint (FUN1 (3, 2, 1))Output:6Keyword delivery: positional
1. Functions and parameters (actual parameters)The creation of a function in Python is Def, the function name is Def f (), the F function name, Def f (A, b), here A-B is two parameters, the function name is custom, and the parameters are custom, so
Return: End Function and return valueNo return: Returns noneNumber of return values = 1 o'clock: Returns a specific valueThe return value is a number + string + list, etc.: Returns a tupleNeed return is required function full calldef test1 ():
First, get the return value:
Can be used as a parameter of a function
For example, define FUN (carray &array)
Using a reference type, you can use the
Second, as function parameters:
#include
//Definition function.
void Ansnode (int num,
Matching principle of function parametersPosition: Match from left to right
In general, the parameter names are passed to the function header by matching the position, and the matching order is from left to right.
Keyword parameter:
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.