1. After opening a file, remember to check whether the file is successfully opened.
This is not only a good habit, but also for usProgramDebugging is also very helpful. Otherwise, we will not find out why the program did not come up with the
Take a look at this sectionCode.
P
=
Malloc (bytes );
If
(P
=
Null)
...
{Printf ("Can't allocate enough memory.");Return 0;}
On the surface, this is very good, considering the insufficient memory allocation is an error. But
C ++ struct memory allocation size 1 principle: 1. The order of all fields in the memory is consistent with the declared Order (theoretically, the interpreter can place fields as needed.) 2. for performance reasons, most compilers actually place
# Include # Include Using namespace STD;
Bool test; // The default initial value of the bool variable is false.
Typedef struct node { Int;Friend bool operator If (A. A Return true;ElseReturn false;}} Nn;
Int main (){
Priority_queue heap;// It
Recently, I used C ++ file operations, in which I used to determine whether a file is empty. If it is empty, I will not read the file. After searching for the file from the Internet for a long time, I did not find it suitable. Finally, I chose the
In the header file of , there are macros of such a group of Operation files.
# DEFINE _ tfdopen _ wfdopen# DEFINE _ tfsopen _ wfsopen# DEFINE _ tfopen _ wfopen# DEFINE _ tfopen_s _ wfopen_s# DEFINE _ tfreopen _ wfreopen# DEFINE _ tfreopen_s _
# Include # include # include // maximum of two values of any type template inline t const & MAX (T const &, t const & B) { return a } // maximum of two pointers template inline T * const & MAX (T * const &, T * const & B) { return * A
# Include # include # include # include # include // STD:: vector is the default value of CONT (default template real parameter) template class Stack { PRIVATE: cont elems; // elements public: void push (T const &); // push element
I was asked the following question when I met Google.
Static class members include static data members and static function members.
A static data member:
When the static keyword is added before the declaration of the data member in the class body,
I. bitwise AND operator &The two quantities involved in the operation are calculated according to the corresponding bit, and0 & 0 → 0, 0 & 1 → 0, 1 & 0 → 0, 1 & 1 → 1
With bitwise AND operation, we can easily clear or take some bits of a number.For
Put it bluntly and directly add the code
. H won't post any comments. Some of them come from a blog post, which is very helpful for understanding. So let's take it.
# Include "arraysh. H"# Include Using namespace STD;
Arraysh: arraysh (INT size
Reprinted with the source: http://blog.csdn.net/sky1415/article/details/4404444
When you see the const keyword, C ++ programmers may first think of const constants. This is not a good conditioned reflection. If you only know that the constant is
The Performance Analysis of class simulation uses a large number of function pointers, structs, and so on. It is necessary to analyze the performance so as to observe the effect of such a structure on the integrity of the program. 1. overhead of
Sorry, it seems that our company's security software limits the size of uploaded files.
3. callback function.
I think this is a C-language innovation. Although it is very simple, it is just like how to put up the eggs, but if you did not expect it,
# Include "stdio. H"
# Include "stdlib. H"
# Include "string. H"
# Include "/usr/include/MySQL. H"
# Include "/usr/include/MySQL/mysql_version.h"
# Include "/usr/include/MySQL/errmsg. H"
Int main (INT argc, char ** argv [])
{
MySQL
Sort () based on quick sorting: unstable sortingMethod 1: Sort (V. Begin (), V. End ())Sorting method: from small to largeMethod 2: Sort (V. Begin (), V. End (), greater ())Sorting method: from large to small
Complexity: O (n log (N) comparisons
1. How to construct a comparison function of STL template for Composite data.
You can define a comparison function for general STL algorithms, such as sorting algorithms or comparison algorithms.
For example:
Bool compare (suitor a, suitor B) {//
1. # include
Void * memcpy (void * To, const void * From, size_t count );
Function:FromCopyingCountCharactersToAnd returnToPointer. IfToAndFromOtherwise, the function behavior is uncertain.
Note: (1) the first parameter is the target pointer, and
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