Description in C ++:
The explicit keyword is used to modify the constructor of a class. The class of the constructor to be modified cannot undergo implicit type conversion. type conversion can only be performed in display mode.
Note:
* The
For an empty class, the compiler generates four member functions by default: default constructor, destructor, copy constructor, and assign value function.
It is best to enable memory detection when using malloc.
If (H = (stud *) malloc
[Thread concept]
To understand the concept of a thread, we must first discuss the concept of a process.
A process is usually definedProgram. In Win32, the process occupies 4 GB of address space. Win32 processes are not dynamic, unlike they are in
Multi-parameter templates must be specific to all parameters. This article provides a solution to the specific single parameter.
For example, use the multi-threaded template in Loki.
Singlethreaded no lock required for a single thread
9ProgramEfficiency
9.1 performance classification of c ++ Language Features
There are many factors that affect the software performance, including the software architecture and operating platform (Operating System/Compiler/hardware platform.
I haven't compiled my code in Linux for a long time. In fact, the biggest headache is the portability of templates. I remember the last time I migrated my Resource Manager to the company's Linux project, it took me a lot of time to coordinate the
In a network server in client-> request server-> response mode, the switch mode is generally used for response processing.
This method is difficult to maintain and lacks error detection.
This document uses the C ++ template to implement a common
Start with the simplest
1. Implement a fixed-size Allocator
// Template class for allocating fixed-size memory blocks, which is implemented by the Internal cache algorithm,
// I use pre-allocated and recycled cache chains.
// Check whether there is
It seems that some people do not quite understand this yet. I tried to use the C code to describe some implementation methods related to the C ++ class.
Classes ABC and BC inherit from a and all have virtual functions F (). The Destructor are
Numeric to string:Use C ++'s streanstream:# Include
# Include
String num2str (double I)
...{
Stringstream SS;
SS Return ss. STR ();
}
String to numeric:Int str2num (string S)
...{
Int num;
Stringstream SS (s );
SS> num;
Return num;
}
The above
We all know a common sense: "Do not return references and pointers to local objects or variables in C ++ ".
Since all c ++ authoritative books require "must not return references and pointers to local objects or variables", why does the C ++
Before discussing global variables, we must first understand several basic concepts:
1. compilation unit (module ):Today, when IDE development tools are widely used, many developers are no longer clear about the concepts of compilation. Many
Tan haoqiang C LanguageHttp://www.codeguru.cn/cpp/TanHaoQiangCA collection of 10 typical algorithmsHttp://www.codeguru.cn/cpp/10bookComplete list of second-level questionsHttp://www.codeguru.cn/cpp/2JiCShiTiJiHigh-quality C ++/C Programming
Recently, a project uses a Thread class of an abstract class. When it is used, it is found that pure virtual functions are sometimes called. The Code is as follows:
Class thread { Public: thread (INT initflag = create_suincluded); ~ Thread ();
The following is a summary of the class considerations:
1. Do not perform too many logic-related initialization in the constructor;
2. The default constructor provided by the compiler does not initialize the variables. If other constructor is
1 constant
Constant values are easier to understand, track, and analyze, so constants should be used instead of variables as much as possible. When defining values
As the default option.
Rule 1.1 uses const constants to replace macrosNote: macros
5. Scope, template, and C ++ other features
5.1 Scope
Principle 5.1 use namespace for classification to avoid symbol conflicts
Note: namespace mainly solves symbol conflicts.
Example: The Global scopes of two different projects have a class Foo,
3 Function
3.1 inline functions
Rule 3.1 inline function is smaller than 10 rows
Note: an inline function has the characteristics of a general function. It differs from a general function only in the processing of function calls. General
Note
Annotations are difficult to write, but they are important to ensure code readability. The following rules describe what to comment and where to comment. Of course, note that annotations are important, but the best code itself is
1. In principle, the row width should not exceed 80 columns, and the 22-inch display screen should be used up;
2. Try not to use non-ASCII characters;
3. Unconditional use of spaces in Unix/Linux, and use of tabs in msvc is understandable;
4.
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service