Загрузка...

Modern C++ syntax for array initialization - August 2022 - 45c173ac

If you declare a local array variable (e.g. int cars[4];) in C++, the elements will have not initialized values. C++ offers many syntaxes for initializing all the elements of an array to zero at the time when the array is defined/declared: int cars[4] = {0}; int cars[4]{0}; int cars[4] = {}; int cars[4]{}; int* cars = new int[4]{0}; delete []cars; int* cars = new int[4]{}; delete []cars; int* cars = new int[4](); delete []cars; int cars[] = {0, 0, 0, 0}; int cars[]{0, 0, 0, 0}; int cars[4]{(0)}; etc.

Видео Modern C++ syntax for array initialization - August 2022 - 45c173ac автора JavaScript и Cybersecurity
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки