Memory allocation knowledge, global, local, static variables
Preliminary knowledge-memory allocation for programsThe memory used by a program compiled by C + + is divided into the following sections1, stack area (stack)-by the compiler automatically assigned to release, store the function of the parameter values, local variables and other values. The operation is
#知识点一:#在函数外面定义的变量叫全局变量num = 100Def AAA (): ‘‘‘If you modify the global variable directly in the function, an exception is generatedIf you really need to modify it, you can declare it in the function (add global above)‘‘‘Global numPrint (num)num+=2Print (num)Def BBB ():Print (num)AAA () #输出100和102The value of the global
a P before the semicolon to define a variable while defining the struct. Another method is the anonymous struct, which can only define variables at one time, because it cannot be reused in the future.
(4) struct array. It is defined and initialized in batches when struct variables are defined. For example, struct person P [3] = {{},{},{}};. But it is rarely used. Struct Arrays can only be initialized when they are defined.
(5) The struct is the same as the array. Variables cannot be defined f
modified in JavaScript scripts. This property has 2 values---"On" and "off". When the property is specified as "on", the page is editable and is specified as "off" when the page is not editable.All elements of the hidden property in HTML5 allow a hidden property, similar to a hidden element in the input element, to inform the browser not to render the element, leaving the element invisible, but the contents of the element are still created by the browser, That is, after the page is loaded, it i
1, undeclared variables are assigned, this variable is the global variable of the Window object allConsole.log (a); A is not defineda=10Console.log (a); 10 equivalent to Console.log (WINDOW.A)function Test () {var a = b = 123; }Test ();Console.log (b) //123 Console.log (a) //a is not defined2. All declared variables are properties of the Window object.var aaa=111;var bbb=222;var ccc=333;Equivalent to window{aaa:111,bbb:222,ccc:333}3, pre-compi
can arbitrarily define a global variable anywhere. Small application seems very convenient, code into scale, after splitting the file, it is finished. Compiler regardless, we can tube.Two different ways:1. All written together, such as the top of the program, good management.2. Write a container of global variables and throw all the global variables in when you
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.