C ++ Primer study note _ 24 _ class and data abstraction (10) -- static and Singleton modes, auto_ptr and Singleton modes, const member functions, const objects, mutable modifiers, constmutable
C ++ Primer study note _ 24 _ class and data abstraction (10) -- static and Singleton modes, auto_ptr and Singleton modes, const member functions, const objects, mutable
comment/* Comment content * * Note: The content of the comment will not be compiled, just explain the description block comment/**..........*/Document comment change (values that can be changed) and constants (values that cannot be changed); Array of operator statements binary, decimal, hexadecimal; conversion between binary ()Eight basic data TypesNumeric: Integer: Byte, short, int (most commonly used), long (for larger data); Floating point (decimal): Float (single precision-) write the data
abstract class. Abstract classes can contain no abstract methods.Other modifiersSynchronized modifierThe method of synchronized keyword declaration can only be accessed by one thread at a time. The synchronized modifier can be applied to four access modifiers.transient modifierWhen a serialized object contains an instance variable that is transient decorated, the Java Virtual Machine (JVM) skips that parti
common modifiers used by classes and their components in Java(1) Classification of modifiers: Permission modifiers:private, default, protected, public status modifiers:static, Final abstraction modifier: Abstract(2) modifiers used for common classes and their composition: of the Modified
DAY04----access Modifiers in the Java languageFirst, access modifiers overview:An access modifier is a modification to a variable or a method or a class that implements some of the necessary permissions after the modification, mainly to explain how the class members are used
I. Some of the modifiers provided in Java that can modify classes, variables, and methods, which are common in Java: abstract (abstract), static (static), public (common), protected (protected), Private ( private), synchronized (synchronous), native (local), transient (temporary), volatile (volatile), final (immutable)
Two. modifier top-level
Definition of Class
Modifier
Meaning
1
None or internal
Classes can only be accessed in the current project and cannot be accessed after other projects are referenced
2
Public
can access the class anywhere
3
Abstract
cannot be instantiated, only for inheritance
4
Sealed
cannot be use
Reprint: http://wuhaidong.iteye.com/blog/851754There are 4 types of access modifiers in the Java languageThere are 4 access modifiers in the Java language: package (default), private, public, and protected.1. The package is the default protected mode, plus a packet access, which is used when there are no
Child class Parent ClassSingle-Inheritance all classes areclass stusent:P erson{//student inherit person class }InheritedSubclasses automatically inherit all of them from the parent class.Members of fields, methods, properties, indexers, etc. as their own membersIn addition to inheriting members of the parent class, subclasses can alsoAdd a new MemberHide or modi
The following two illustrations illustrate the same project:The accessibility of the class is two levels: public and internal;Classes marked as pubic can be accessed by code in any assembly within the system. If a class is visible to other assemblies,Use the public access modifier! A class marked internal can only be seen by classes in the assembly in which it re
Questions for class member modifiers
Class a{ private static $p 1; public static $p 2;}
As in the code above, the member variable is preceded by the private static modifier and only with the private difference where? Similarly, where is the difference between public static and public?
------Solution--------------------
Static keyword: Declaring a
Java modifiers can be divided into two types
Accessible modifiers
Non-accessible modifiers
Using modifiers, you can use the definition of the class, method, variableAccessible
(self):PrintC.__nameclassD (C):defShow (self):PrintC.__nameC.__name #class Access ==> errorobj=C () obj.func ()#The ==> within the class can access the correctObj_son=D () obj_son.show ()#==> errors can be accessed in derived classesNormal field
Public common fields: objects can be accessed, accessible within classes, and accessible in derived classes
Private Normal field: Only within th
cycle of an object is determined by the braces {} defined by the object. Each time a program executes a flow into a statement block, the object of the statement block's automatic lifecycle will be created and initialized at the same time.
Iii. Storage Class Modifiers(1) AutoThe auto modifier can only be used for object declaration in the function. Objects with auto mod
A. Some modifiers are provided in Java that can be used to decorate classes, variables, and methods, and in Java common modifiers are: abstract (abstract), static (static), public (common), protected (protected), Private ( private), synchronized (synchronous), native (local), transient (ephemeral), volatile (volatile),
Java has four access rights, three of which have access modifiers, private,public and protected, and one without any modifiers. Where the package represents the default access rights, the code is the default case where no modifiers are written. For the sake of good, name the package for the moment. PublicprotectedPriv
modifiers). constructs blocks of code: You can initialize non-static properties, and construct code blocks that take precedence over constructor execution and can be placed in constructors. Static blocks of code: You can initialize static properties, load when classes load, and not in constructors. Second: final: Decorated class: The final class, the final
accesses it, it is the same copy.Instance methods and instance variables cannot be accessed directly in a static method.The This and Super keywords cannot be used in static methods.Static methods cannot be modified by an abstract.Static member variables can be accessed using either the class name or the object, and non-static member variables can only be accessed using the object.Static functions can access static members directly, but they cannot ac
Tag: code specifies default visibility. SH Engineer Strong Object StatOne, Java access modifierAccess modifiers to control the visibility of members in a classThere are four access modifiers, respectively: default,private,public,protected1, default: No write modifiers are required by default. can only be accessed withi
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.