First, the String class: (Belongs to the class type)-string (only in C + +)
You must learn to introduce the string type before use:
Introduction of String header file (System header File): #include <string> PS: header file is not string.h
1. Definition string: String a= "abc"; String b= "Abd";
2. String comparison: From left to right from the first character, compared to the size of the ASCII code
From the beginning look: A==a,b==b,c>d so a>b;
3. String array: The element string in the string array does not have an end bit such as '/';
Second, constant and variable
1. What is a constant:
Value cannot change the amount of 1 1.2 fixed value
Types of constants:
(1) Numeric constants (integers, floating-point numbers);
(2) Character-type constants (character constants, escaped character constants, string constants)
(3) Symbolic constant (#define constant value of the constant name of the symbol)
2. Variables
(1) Variables
The amount of value that can be changed during program run becomes variable;
Naming rules for variables: C + + Specifies that identifiers can only be composed of letters, numbers, underscores, and can only be case-sensitive by letter and underscore
Keywords and reserved words cannot be used;
(2) Constant variable
Variable with const keyword, program run time value cannot be changed, call constant variable
PS: The constant variable must be initialized at the time of definition, and thereafter his value cannot be changed;
Third, operator
1. Arithmetic operators:
+-*/% + +--
Subtraction dividing the remainder from adding self-subtraction
2. Relational operators:
> < = >= <=! =
Greater than or equal to or less than equals not equal to
The return value is bool (the return value in the C language is 0 and 1)
3. Logical operators:
&& | | !
Logical AND logical or logical non-
The two values before and after the logical operators are bool (the C language must be 0 and not 0 values);
&&: All true is true, as long as another one is false;
|| : As long as one is true;
! : Contrary to current;
4, Bitwise operators:
<< >> & | ^ ~
Bitwise LEFT SHIFT bitwise RIGHT SHIFT bitwise VS. bitwise OR bitwise XOR or bitwise REVERSE
Original code anti-code complement
5. Assignment operator =
(1) Meaning: Assigns the value to the right of the assignment operator (including the result of the last operation of the expression) to the variable to the left of the assignment operator;
A=1;
(2) Right binding of assignment operation
NDK and C language basic syntax (ii)