C ++ knowledge of discrete points

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.
  • stringFormer type to addstd::
  • Defined std::string a="123456", so a[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 stackno reservemethod. (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 a aa.size()is 0, aa.size()-1not -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.

Related / Reference Links

发布了88 篇原创文章 · 获赞 61 · 访问量 2万+

Guess you like

Origin blog.csdn.net/a435262767/article/details/103361651