member variables :
Variables written in curly braces of class declarations, which we call member variables (attributes, instance variables)
Member variables can only be accessed through objects
Note: Member variables cannot leave a class and are not member variables after leaving the class
Member variables cannot be initialized at the same time as defined
Storage: Heap (in the storage space of the heap that corresponds to the current object)
Data stored in the heap is not automatically freed and can only be manually released by the programmer
@interface person:nsobject{ int _age; *_name;} @end
Global variables:
Variables that are written outside the function and curly braces, which we call global variables
Scope: Starts from the defined line and continues to the end of the file
A local variable can be initialized at the same time as the initialization, or it can be defined.
Storage: Static Zone
When the program starts, it allocates storage space until the end of the program is released.
int A; int ten;
Local variables:
Variables written in functions or blocks of code, which we call local variables
Scope: Starts with the defined line, until it encounters curly braces or return
Local variables can be initialized or defined at the same time.
Storage: Stacks
The data stored in the stack has a feature that the system will automatically release to us
int Main (intconstChar * argv[]) { // like this is written in {}, or in a function , {} ended or the function died of intten; { int value; } return 0 ;}
Zhang OC Basics Review 02_ member variables (attributes), local variables, global variable differences