1基於範圍的for循環
c++
double array[5] = {1.1,2.2,3.3,4.4,5.5} for(double x : array) { cout << x << " "; } cout << endl;
2auto數組
c11容許以下代碼spa
std::vector<double> scores; auto pv = score.begin();
3c11初始化數組能夠省略等號,能夠直接所有初始化爲0:指針
double array[4] {};//初始化爲0.
4右值引用code
double && rref = std::sqrt(36.00); double j = 15.0; double && jref = 2.0*j +18.5; //移動語義(move semantics)
5在c++primer plus 264頁orm
struct free_throws { std::string name; int made; int attempts; float percent; } ... const free_throws & clone(free_throws & ft) { free_throws *pt; *pt = ft; return *pt; }
free_throws & jolly = clone(three);
個人理解是返回了一個free_throws類型的一個const引用(對麼?)這個引用指向(指針說指向,引用應該怎麼表述?)的空間和& ft指向的空間不是同一個.three
要記得delete回收空間,(new被隱式)ci