You need to use the initialization member list in the following three situations:
First, the data member that needs to initialize is the case of the object;
Second, class members that need to initialize the const modifier;
Third, the reference
Document directory
This is my reading notes and I hope it will help you learn Java.All codes are tested. test environment:Java version "1.4.0-RC"Java (TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)Java hotspot (TM)
The initialization syntax is unified in the C ++ 11 standard. Before learning about these changes, we need to understand the aggregate and POD types, I saw a good article on Stack Overflow (original article). I have a detailed explanation of the
ArticleDirectory
Const member functions
Name Search
Constructor initialization list
Default constructor
Implicit type conversion
Const member functions
A member function can be reloaded based on whether the member function
C ++ struct
1. The C ++ struct has the default constructor.
#include
using namespace std;struct node{ int m,n;};int main(){ node a; printf("%d %d\n",a.m,a.n); return 0;}
Running result:
Because the default constructor does not
The basic operations of the stack include using namespace std;const int maxn = 3;typedef struct stack{//numtype num; int num;} Stack;int top = 0;//The previous element in the position of the current element, stack Stack[maxn];bool is_empty (), bool
Source: Click to open the link
The order of Java class initialization is often confusing, and now this article tries to give the JVM an explanation by experimenting with the initialization order of classes in the Java non-inheritance and inheritance
C + + Initialization list
What is a list of initialization
Unlike other functions, constructors can have initialization lists, in addition to names, argument lists, and function bodies, which begin with a colon, followed by a series of
1. Java initialization order without inheritance:
Class Sample{Sample (String s){System.out.println (s);}Sample (){SYSTEM.OUT.PRINTLN ("sample default constructor called");}Main functionpublic static void Main (String str[]){Test a=new test
What is a list of initializationUnlike other functions, constructors can have initialization lists, in addition to names, argument lists, and function bodies, which begin with a colon, followed by a series of comma-delimited initialization fields.
In c++11, the default functions and deleted functions allow you to explicitly control whether special member functions are automatically generated. A deleted function can also provide you with a simple language to prevent problematic type elevation
Objective
When you define a variable that does not have an initialization, the system sometimes helps us initialize the variable.
How the system initializes depends on the type of the variable and the location of the variable definition.
Whether
when we beginner C + +, we may have some doubts about the constructor of the class, the copy constructor, and the destructor. Organize the following (personal opinion, if there is a mistake, also look at it.) ):1. ConstructorsAccording to the
C ++ initialization list (1)What is the initialization list?
Unlike other functions, constructor can have an initialization list in addition to the name, parameter list, and function body. The initialization list starts with a colon, followed by a
What is a list of initializationUnlike other functions, constructors can have initialization lists in addition to names, argument lists, and function bodies, and initialization lists begin with a colon followed by a series of comma-delimited
Constructor Concept
(1) The constructor isSpecial member functions
(2) When creating a new object of the class type, the system automatically calls the constructor.
(3) constructor is used to ensure that every data member of the object is correctly
Chapter 2 object of everything1. All objects must be created by you1. Where is the storage?1. Register: we cannot control it in the program2. stack: stores basic data and object reference, but the object itself is not stored in the stack, but in the
14 InitializationInitialization is the preparation phase of the instantiation of classes, structs, and enumeration types. This stage sets the initialization values for the properties stored by this instance and makes some preparations before using
Constructor, is a special method. It is used primarily to initialize an object when it is created, to assign an initial value to an object member variable, and to always use the new operator in the statement that creates the object. A particular
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.