C++ brief introduction

C++ variable naming rules

1. The name can only contain letters, characters, numbers and underscores (_)
2. The first character of the name cannot be a number
3. Distinguish between uppercase letters and lowercase letters
4. C++ keywords cannot be used as names
5. There is no length limit for C++ names, but the platform has length Restrictions
6. Names starting with two underscores or an underscore and a capital letter are reserved for use by the implementation (the compiler and the resources it uses). Names starting with an underscore are reserved to implementations for use as global identifiers.
If you need to have two or more words, you can use an underscore to connect them, or the first letter of the second word should be capitalized.

type of data

integer type
char short int long longlong(c++11)
char represents character
short at least 16 bits (SHRT_MAX: stores the maximum value)
int is at least as long as short (INT_MAX...)
long is at least 32 bits, and at least as long as int (LONG_MAX )
longlong At least 64 bits, at least as long as long (LLONG_MAX)

The sizeof operator returns the length of the type or variable, in bytes
There is a file climits that saves some symbolic constants.

C++ variable declaration

Declare the variable before using it for the first time.
C++ can perform continuous assignment of variables: int a = b = c = 88; assignment from right to left
C++ uses cin for input; uses cout for output.

Function naming

type functionname(void); indicates that the function does not accept any parameters. A function that returns a value is called a function, and a function that does not return a value is called a procedure.

Guess you like

Origin blog.csdn.net/weixin_43915090/article/details/134045424