C++ features
- Compatible with C language and support process-oriented programming;
- Support object-oriented programming language;
- Support generic programming.
Simple procedure:
#include<iostream>//include 编译预处理命令
using namespace std;//std 命名空间,防重复
int main()//int 整数值
{
cout<<"搁这干啥呢"<<endl;//cout是输出流 <<是输出流运算符 endl是行(hang)结束符
cout<<"小老弟"<<endl;
return 0;//返回该函数的计算结果,谁用返回谁
}
The result is·
C++ character set
- Uppercase and lowercase English letters. A to Z a to z;
- Numeric characters: 0~9;
- Special characters: ! # &%
C++ word formation
- C++ predefined words-keywords ( bool, char, const, float, false, true, etc. );
- Identifier: the word declared by the programmer;
- Text: Data directly represented by symbols in the program (literal meaning);
- Separator: "()" "{}" "," ":" ";"
- Operators: +, *, -, /
- White space: a general term for spaces, tabs (characters generated by TAB), vertical tabs, line feeds, carriage returns, and comments.
Identifier composition rules
- Start with uppercase and lowercase letters and underscore;
- It is composed of uppercase and lowercase letters and underscores or numbers 0-9;
- Uppercase and lowercase represent different identifiers;
- It cannot be a C++ keyword or operator.
type of data
1. Data in the program
- Constant-data written directly in the source program, the value cannot be changed during the entire program running.
- Variables-data that is allowed to be changed during program execution.
2. Data Type
1. Basic integer types:
integer- int -number of bytes: 4- value range : -2 of 31 to 2 of 31-1 ( minus one )
by sign: signed-signed, unsigned ——Unsigned;
According to the number of bytes/data range:
short integer—— short —— number of bytes: 2—— value range : -32768~32767
long integer—— long —— number of bytes: 4—— Value range : -2 31~2 31-1 ( minus one )
long integer—— long long ——Number of bytes: 8—— Value range : -2 63~2 63-1 ( minus A )
Character type- char -number of bytes: 1 ( the code that exactly stores one character ) -value range : -128~127 ( 128-1 )
//The code that accommodates a single character, essentially storing an integer
2. (Real number) floating point type
Single precision- float -number of bytes: 4- absolute value range : 3.4 * (10 of -38) ~ 3.4 * (10 of 38)
double precision- double -word Number of sections: 8- Absolute value range : 1.7*(10 of -308) ~ 1.7*(10 of 308)
Extended precision- long double -Number of bytes: 8- Absolute value range : 1.7*(10 of 308) -308)~1.7*(10 of 308)
Too difficult, the original poster will not use the power symbol, but the above value range is the key point. Akhabaka
3. Escape characters
Character constant form | ASCll code | meaning |
---|---|---|
\a | 07 | Ring the bell |
\n | 0A | Wrap |
\t | 09 | Horizontal tab |
\ v | 0B | Vertical tab |
\b | 08 | backspace |
\r | 0D | Carriage return |
\f | 0C | Change page |
\\ | 5C | character"\" |
\" | 22 | Double quotes |
\’ | 27 | apostrophe |
\? | 3F | question mark |
4. Style string constant*
- A pair of double-guided, well-enclosed character sequences;
- Stored in the memory in the sequence of characters in the string, each word occupies one character;
- Add'\0' at the end as an ending mark.
For example:
"CHIMA"————[ C] [H] [I] [N] [A] [\0]
"a"————[ a] [\0]
'a'———— [a]
5. The type of character constant or string constant can be changed by adding a prefix
Prefix | meaning | Types of |
---|---|---|
u | Unicode 16 characters | char |
U | Unicode 32 characters | Wrap |
L | Wide character | Horizontal tab |
u8 | UTF-B is only used for string subface constants | Vertical tab |
The host was lazy and tired and wanted to drink water, so he went offline. Come on.
Believe in yourself, one day you will become a bald ouye.