C++ simple programming basic content Mikabaka (º﹃º)

C++ features

  1. Compatible with C language and support process-oriented programming;
  2. Support object-oriented programming language;
  3. 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·
Insert picture description here

C++ character set

  1. Uppercase and lowercase English letters. A to Z a to z;
  2. Numeric characters: 0~9;
  3. Special characters: ! # &%

C++ word formation

  1. C++ predefined words-keywords ( bool, char, const, float, false, true, etc. );
  2. Identifier: the word declared by the programmer;
  3. Text: Data directly represented by symbols in the program (literal meaning);
  4. Separator: "()" "{}" "," ":" ";"
  5. Operators: +, *, -, /
  6. White space: a general term for spaces, tabs (characters generated by TAB), vertical tabs, line feeds, carriage returns, and comments.

Identifier composition rules

  1. Start with uppercase and lowercase letters and underscore;
  2. It is composed of uppercase and lowercase letters and underscores or numbers 0-9;
  3. Uppercase and lowercase represent different identifiers;
  4. It cannot be a C++ keyword or operator.

type of data

1. Data in the program

  1. Constant-data written directly in the source program, the value cannot be changed during the entire program running.
  2. 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*

  1. A pair of double-guided, well-enclosed character sequences;
  2. Stored in the memory in the sequence of characters in the string, each word occupies one character;
  3. 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.

Guess you like

Origin blog.csdn.net/weixin_45465460/article/details/108268664