Static member variables are stored in the data segment and are generated at compile time, with the following characteristics:A static member variable is actually a global variable in a class domain, and its initialization should also be the same as
[Cpp]# Include # Include # Include Using namespace std; Class{Public:A ();Static void GetStaticNum (); // static function Void GetNum (); // Common Function Void UseStatic (); // call a static function Int j; // common variable MemberStatic int I; //
C/c ++ interview Summary (1) Interview Summary
I have recently been looking for a new job and have encountered many interview questions. Most of them have made me very embarrassed. Once again, I realized that my knowledge is lacking. my previous job
In C + +, a static member is an entire class rather than an object, and a static member variable stores only one copy for all objects to be shared. So it can be shared across all objects. Using static member variables to implement data sharing
Sixth day notesStatic modifiers static:a . Static Modifying member Variables :
Static is used to modify a member variable to be called a statically member variable, and a member variable without a static modifier is called a non-static
Example 1:1 Public classTest {2 inti = 47;3 Public voidCall () {4 for(i = 0; i ){5System.out.print (i+ "");6 if(i = = 2){7System.out.println ("\ n");8 }9 }Ten } One PublicTest () { A } -
1. "Force" avoids accessing static or static methods of this class through the object reference of a class, unnecessarily increasing the compiler parsingIt can be accessed directly using the class name.2. "Mandatory" all the Overwrite method, must
Rules for Initialization order1. When an object of a class is instantiated, the member variable is initialized first before the constructor is called, regardless of the order of writing. If there is no explicit initialization before the constructor
1. Object and LockEach instance of the object class and its subclasses has a lock. Where scalar type int,float is not an object type, but a scalar type can be used as a lock by its wrapper class. Individual member variables cannot be marked as
Introduction of today's contentU Knowledge ReviewU static keywordU code blockChapter 1th Knowledge Review1.1 Review of methods1.1.1 Case Code One:Package com.itheima_01;/** Requirements: Define a method to calculate the number of two and invoke it
A class variable is also called a static variable, that is, a variable that is static before the variable;
An instance variable is also called an object variable, that is, a variable without static;
The difference between the two is:
A class
1. servlet Execution ProcessThe client issues an HTTP request, the Web server forwards the request to the servlet container , the servlet container resolves the URL and finds the corresponding servlet based on Web. XML, and passes the requests,
Static member: the member with the Static keyword added before the definition. As follows:classcrectangle{ Public: Crectangle (); ~Crectangle (); Static voidprinttotal ();Private: intW, H; Static intNtotalarea; Static intNtotalnumber;};
11th Chapter
Class inheritance
Subclasses inherit the data fields and methods that are accessible in the parent class, and subclasses can also add new data fields and methods.Subclasses do not inherit the constructor of the parent
The answer is heap memory.Before clearly reading the Java class initialization process,But suddenly see such a topic, still ignorant.After Baidu, those post reply each have each say,The head can see the fortress live, or read the book to prove
Local variablesDefinition: A variable defined within a method is called a "local variable" or "temporary variable", and the memory occupied by the local variable is freed after the method ends.Global variablesDefinition: A global variable, also
Polymorphic: A reference to a parent type can point to a child object.
Parent P = new Child (); When using polymorphic mode, first check if there is a sing () method in the parent class, if not, compile the error, and if so, then call the
Yang 77, you are more powerful than me ...
but I can be more you than you ... Anger Brush ...
public static Test t1 = new Test ();
public static Test t2 = new Test ();
{
System.out.println ("Building Block");
Microsoft Asia Technology Center's face test ...
1. The difference between a process and a thread.
A thread is a unit of execution within a process and a scheduled entity within a process.The difference from the process:(1) Dispatch: As the
Note:
C ++ static member variables are member variables modified with static, not part of the object but part of the class. Therefore, static member variables can be used when no object is instantiated. But it must be initialized.
It must be
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.