Proficient classes and objects
This article is based on the knowledge of classes and objects that you already know.
Dynamic Memory Allocation in the object:
If the memory is dynamically allocated to the object, the memory should be
Const summary in C ++
I. Basic statements1. Const int r = 100;// Standard const variable declaration and initialization, because the default internal connection must be initialized, its scopeFor this file, the compiler directly replaces it with 100
Recently, I decided to review Lippman's masterpiece "C ++ primer", record some important knowledge points during the Query Process, and hope to help myself. For ease of query, all content is classified by chapter.Chapter 1 Quick Start
1. The
Effective C + + Chapter 1. Make yourself accustomed to C + + (Accustoming yourself to C + +) Item 3. Use const (using const whenever possible) whenever possible1. Const and semantic constraintsconst allows you to specify a semantic constraint (that
1. the type in the data definition can be either a built-in data type or a class type, except for the reference data type , the type of the array element is any data type. Not all elements are arrays of reference data types. 2. The dimensions of
1. Defining and initializingA) The function of the const qualifier is to convert an object to a constant, and the use of const can improve the security and reliability of the program to some extent.These two definitions are completely equivalent,
A const object, a pointer to a const object, a const pointer (known by a polygon question)1.Const Object(1) on the const, many enterprises of the written test, interview will appear, very simple, asked you "The meaning of const?" ”。I do not know the
C ++ const qualifier
Const qualifier:Use const to restrict objects so that the value of a const object cannot be changed once it is created.
When defining a const object, you must initialize it in either of the following ways:
const int x = 10;
/* Const function Summary (Author: mingyuanonline # gmail.com)
* To declare a const member function, you only need to add the const keyword between the function parameter table and the function body. (This sentence has been changed. For the original
Const objectDefine an object as an unchangeable object, called a const object.For example, const int A = 512;Note: Because the const object cannot be modified after definition, it must be initialized during definition.
Const referenceC ++ primer
1. overload of const member functions and non-const member functions of the class
#include #include using namespace std;class Person{public:Person() {}Person(string name, string address) : mName(name), mAddress(address){}string&
1. const reference
1. Non-const reference, can only be bound to objects of the same type;
1.2.const reference: How can I bind a reference to an object of different but related types or to the right value;
double a = 3.14;const int &b = a; //right2.
What is type conversion?The meaning of type conversion is to change the expression of a variable by changing its type to another type. To convert a simple object to another object of type conversion, you will use the traditional type conversion
Overview:The source code of the C preprocessor handler, which runs before the compiler, usually begins with the symbol #.Also involves static, const knowledge points ... Some are similar to Java ... Some easily confuse t.t.Many of the chapters in
What is type conversion?
The meaning of type conversion is to change the expression of a variable by changing its type to another type. To convert a simple object to another object of type conversion, you will use the traditional type conversion
1,Cin LanguageConstwith theC + +in theConstvoid Main () { const int a = ten; int *p = (int*) &a; *p =; printf ("%d", a);}Compare the above code in C and C + + to Execute the result:C: print ;C + + : Print 0 . Thus, the const in C is a
What is type conversion?
The meaning of a type conversion is to change the way the variable is represented by changing the type of the variable to another type. To convert a simple object for a type to another object you will use the traditional
1. by Default,constObjects is Local to a FileBy default, the const object is localThis is the original in "C + + primary 5th."When a const object was initialized from a Compile-time constant, such asDefinition of BufSize:
Const int
I. Definition and initialization of arrays1. Definition of Arraysthe dimensions of an array must be defined with a constant expression greater than or equal to one, which can contain only integer literal constants, enumerated types, or integers
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.