20150429
Use character type data to represent a single character
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/93/wKioL1XnWXHzLnIqAADwMkc4Flo846.jpg "title=" capture. PNG "alt=" Wkiol1xnwxhzlniqaadwmkc4flo846.jpg "/>
Represents Unicode characters
With wchar_t, it occupies 2 bytes and can represent a larger range of characters.
wchar_t cchinese=l ' in ';
Wcout.imbue (the locale ("CHS"));
wcout<<cchinese<<endl;
C + + does not have a single, so-called string type. The basic_string in the general Si he STL represents a string, essentially a wrapper over a character array.
Character array, each position holds one character, and "0" indicates the end of the string.
If you are wrapping an array of type char, the string type is strings.
If you are wrapping an array of type wchar_t, the string type is wstring.
string example
String strmorning ("Good morning!");
cout<<strmorning;
wstring Example
Wstring Strchina (L "China");
Wcout.imbue (the locale ("CHS"));
wcout<<strchina<<endl;
For a string variable of type wstring, you need to use the Wcout object when outputting, and you need to set the encoding of the character with imbue ()
String provides a look-up character length that provides for finding a character;
String strmorning ("Good moring!");
int Nlength=strmorning.length ();
String::size_type npos=strmorning.find (' O ');
The length of cout<<strmorning<< "is:" <<nlength<< "\ n in position" <<npos<< "has a character 0. "<<endl;
Array
One-dimensional arrays have a []
There are 2 of two-dimensional arrays []
Three-dimensional array of 3 [][][]
int nsalary[100]; Indicates that there are 100 integers that can be stored in this array
float farray[2][3]; Indicates that there are 2*3 elements, each of which is floating-point type.
int point [100][100][100]; Represents a 100*100*100 element, with the type of each element being an integral type.
Array Syntax format
Data type array name [number of constants] [number constants] ....
The number constant must be an integer of type unsigned int
The application of the array: The number is large, the same data type, the same processing method.
Array initialization:
int narray[5]={1,2,3,4,5};
All can be initialized or partially initialized, and elements that are not initialized default to the default initial value of the corresponding data type.
Float farray[2][3]={{2.4,3.4,4.2},{2.6,3.2}};
This array is 2 rows and 3 columns, now the last number is not given, so the system will initialize this number to the default initial value of floating-point numbers
The index of the array indicates the position of the number in the array
int nsalary[100];//defines an integer array of length 100
int n=nsalary[24];//reads the 25th element in the Nsalary array
The meaning of this statement is to assign the 25th data in the Nsalary array to the variable N.
Nsalary is a defined array name, and 24 indicates that the data to be referenced is the 25th data in the array.
Subscript in a C + + array always starts with 0
The same for two-dimensional arrays
float fa=farray[1][1];
This statement accesses the 2nd Column element in the second row of the Farray two-dimensional array.
An enumeration type is a list of all possible values for it.
When a variable is defined using an enumeration type, the value of the variable is limited to the range of possible values enumerated by the enumeration type.
The syntax structure of an enumeration type is:
Enum Enum type name
{
List of possible enumeration values
};
c++--Study notes 006