"The new standard C ++ programming" 1.1-1.6 (C ++ Learning Notes 1)

1, cout output
cout << << items to be output to be output item ????? << 2;
2, CIN input
cin >> >> Variable Variable 1 >> ????? 2;
. 3, C ++ programs typically comprise two heads line

4, header files,
some of the commonly used C language header files in C ++ name was changed to remove the ".h", and add character c at the beginning
eg. # include
5, cast
in C ++ cast can be written: type name (expression to be converted)
6, reference (faithfulness)
type reference name & name = name of a variable of the same type
when the reference constant is defined ① Note: to initialize a variable to reference
② after initialization, it has been the variable is referenced, will not quote other variables
③ reference can only reference variables, constants, and expressions can not reference
7, parameters passed by reference (bi-change value)
. eg exchange of a, b values
void Swap (int & a, int & B)
{
int tmp;
tmp = a;
a = B;
B = tmp;
}
. 8, const keyword
(1) defines constants
similar now define C language
(2) define a constant pointer
eg.const int * n-P = &;
① the content thereof is not directed by a constant pointer, the pointer to be constant changes
cast unless ② can not use a constant amount of the pointer is assigned to the pointer,
③ function parameters when the pointer is constant, to avoid accidentally changing the contents of the internal parameter function pointer locations
(3) defines the constant reference
const int & r = n;
Often the difference between ordinary and references cited: can not normally modify the reference to the content of references
cited type const T const T & often variable and can not be used to refer to types of T & initialize type, unless mandatory conversion

Guess you like

Origin www.cnblogs.com/cyn522/p/12239328.html