当前位置:网站首页>Basic knowledge of functions and special points

Basic knowledge of functions and special points

2022-07-28 07:13:00 So and so Xiao Lu

  1. function .( High cohesion and low coupling as much as possible )
  • C Classification of functions in language :
  • Library function
  • Custom function
  • But a secret that library functions must know is : Use library functions , Must contain #include Corresponding header file .

Here, learn the above library functions by referring to the documentation , The purpose is to master the use of library functions .

  • You need to learn how to use query tools :

MSDN(Microsoft Developer Network)

www.cplusplus.com

cppreference.com( English version )

cppreference.com( Chinese version )

  • Formal parameters and actual parameters

Actual parameters : The parameters that are actually passed to the function , It's called the actual parameter .

The argument can be : Constant 、 Variable 、 expression 、 Functions, etc .

Shape parameter : Formal parameters refer to the variables in brackets after the function name , Because formal parameters are only instantiated when the function is called ( Within distribution

deposit receipt element ), So it's called formal parameter . Formal parameters are automatically destroyed when the function call is completed . Therefore, formal parameters only exist in functions

effect .

example : Function call exec((vl,v2),(v3,v4),v5,v6); in , The number of arguments is :( )

example :

Among them a and b Is the argument ,*px and *py It's a parameter .

  • Function call :

Value transfer call , Pass a value , The address was not passed

The formal and actual parameters of a function occupy different memory blocks , Modification of a parameter does not affect the argument .

Address call

Address call is a way to call a function by passing the memory address of the created variable outside the function to the function parameter .

This parameter transfer method can establish a real relationship between the function and the variables outside the function , That is, you can directly operate inside the function

As a variable outside the function

  • Nested function

Nesting is to call a function inside other functions , To recycle , Achieve an effect similar to the cycle , But it reduces the code .

  • Chained access

Take the return value of one function as the parameter of another function

  • Declaration of functions

If the definition function is after the use function , Declare the function before using it , The declaring function should be declared in the main function

If you define a function before using it , You can use functions directly without declaration . Therefore, we usually define the function first before using the function

  • Function recursion

Recursion simply means calling your own functions , So as to achieve the effect of the function .

Two necessary conditions for recursion

There are restrictions , When this constraint is met , Recursion doesn't continue .

After each recursive call, it gets closer and closer to this constraint

example : Recursively print each bit of an integer

  • The creation and destruction of function stack frames
  • register

It is divided into eax、ebx、ecx、edx、 as well as ebp and esp

Every function call has to create a space in the stack

main It is also called by other functions .

__tmainCRTStartup Of this function esp and ebp Go through some operations , by main Function creates a space , And then ebx and esi and edi, To operate

原网站

版权声明
本文为[So and so Xiao Lu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280516553531.html