Directly on the code:Code Listing 1: Public classConstrocttest {Private StaticConstrocttest test =Newconstrocttest (); //static variable sta1 not given an initial value Public Static intsta1; //static variable sta1 gives the initial value
The difference between static class and static variable usage in PHP, PHP variable
This paper analyzes the difference between static class and static variable usage in PHP. Share to everyone for your reference. The specific analysis is as
Original blog, reprint please indicate the source--Zhou Xuewei http://www.cnblogs.com/zxouxuewei/Static is used in two ways: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables
1. Constants: Also known as final variables, can only be assigned once in the entire programfinal int num = 1215;num = 1216; //error, can only be assigned once2. Class member variable: A variable that is not defined in a method is a member variable,
The type descriptor of a static variable is static, and a non-static variable instead of a type specifier is not static. This article mainly introduces the difference between static and non-static variables, I hope to help you to see
C ++ Primer study note _ 22 _ class and data abstraction (8) -- static member variable, static member function, class/object size, _ 22 -- static
I. static
Each static data member is an object associated with the class and is not associated with the
Static is the definition of a static object or a static variable, and what are the characteristics of a variable or class method that is defined by static? We've seen the relevant examples of this article.
1. Create the object $object = new Class (),
static variables
The static variable is on the stack and is a global variable that has been generated at compile time.
public class Cow
{public
static int count;
private int id;
Public Cow ()
{
id = ++count
}
}
The client creates 2 cow
create another class in one class, called the member inner class. This member inner class can be static (with the static keyword decorated), or it can be non-static. Since static internal classes are defined and used, there are various
Analysis of the difference between static class and static variable usage in PHP
Static is the definition of a static object or a static variable, and what are the characteristics of a variable or class method that is defined by static? We've seen
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.