Summary
C ++ knowledge of discrete points
- In a different source file can define (end of the current source file #define macro scope from the beginning to the) same macro
- Prevent duplicate file header contains means: to prevent the repeat of a source file that contains the same header file twice, but the same header file can be simultaneously, each containing a different source files.
- General class defined in the header file, the function defined in the default class
内联(inline)
, and in the class declaration, a function is not defined outside the class as a default内联(inline)
. - Variables defined in the header file is automatically added
extern
. - Several methods defined functions in the header file:
- Declaring class, define static member functions in a class, and implement functions in the header file.
- Using a template function (which requires declarations and definitions in the header file)
(没有试过)
. - It is defined as inline functions
inline
.
C ++ syntax
- Negative remainder and quotient are negative. For example
-123 / 10 = -12
,-123 % 10 = -3
. string
Former type to addstd::
- Defined
std::string a="123456"
, soa[a.length() - 1] == '6'
instead'\0'
. char a = ''
We will complain because it is not initialized to empty characters. It will have to be at leastchar a = '\0'
- Note: Stack
stack
noreserve
method. (TODO: C ++ prime or algorithm design and analysis seems to have summed up what the structure contains reserve, look) - Note that the vector size is unsigned. For example
vector<int> aa;
, when aaa.size()
is 0,aa.size()-1
not -1 but a maximum unsigned number.
C ++ library functions
int isalnum ( int c )
:头文件\<ctype\>
Check character is not a letter or number (alphanumeric).int tolower(int c);
: ,头文件\<ctype\>
A character will be converted to lowercase characters.