- There are four kinds;
- A public scope means that member variables can be accessed everywhere;
- A private scope can only be accessed directly from the object methods of the current class, such as PERSON.M; if the subclass needs access, it needs to pass the set and get methods;
- Protection scopes can be accessed directly in the object methods of the current class and subclass;
- The private variables of the parent class cannot be accessed directly in the subclass, but there are private variables that need to be accessed through the set and get methods;
- Do not write anything, the default is protected;
- @public: The member variables of an object can be accessed directly from anywhere
- @private: can only be accessed directly in the object method of the current class;
- @protected: can be accessed directly in the object method of the Money class and subclass (default is @protected)
- @package: The member variables of an object can be accessed directly in the same frame;
- The member variable in the. h file is protected by default, and the member variable in. m is private by default, even if it is written as @public; The subclass is also private. The member variable name declared in the. m file cannot be the same as the one in the. h file, unless it is placed in the. main file for direct access;
- Super class is the parent class superclass
Member Variable scope: OC