Мне кажется ты путаешь с #include <array> std::array<int,5> myints; std::cout << "size of myints: " << myints.size() << std::endl; Код #include <array> std::array<int,5> myints; std::cout << "size of myints: " << myints.size() << std::endl;
Что то ты нахуежопил там main.cpp: In function ‘int main()’: main.cpp:15:18: error: expected identifier before numeric constant int nums[] = [4, 5, 7, 9]; ^ main.cpp:15:19: error: expected ‘]’ before ‘,’ token int nums[] = [4, 5, 7, 9]; ^ main.cpp: In lambda function: main.cpp:15:19: error: expected ‘{’ before ‘,’ token main.cpp: In function ‘int main()’: main.cpp:15:19: error: initializer fails to determine size of ‘nums’ main.cpp:15:19: error: array must be initialized with a brace-enclosed initializer main.cpp:15:21: error: expected unqualified-id before numeric constant int nums[] = [4, 5, 7, 9]; ^ main.cpp:17:28: error: request for member ‘size’ in ‘nums’, which is of non-class type ‘int [1]’ for(int i = 0; i < nums.size(); i++){ ^ Код main.cpp: In function ‘int main()’: main.cpp:15:18: error: expected identifier before numeric constant int nums[] = [4, 5, 7, 9]; ^ main.cpp:15:19: error: expected ‘]’ before ‘,’ token int nums[] = [4, 5, 7, 9]; ^ main.cpp: In lambda function: main.cpp:15:19: error: expected ‘{’ before ‘,’ token main.cpp: In function ‘int main()’: main.cpp:15:19: error: initializer fails to determine size of ‘nums’ main.cpp:15:19: error: array must be initialized with a brace-enclosed initializer main.cpp:15:21: error: expected unqualified-id before numeric constant int nums[] = [4, 5, 7, 9]; ^ main.cpp:17:28: error: request for member ‘size’ in ‘nums’, which is of non-class type ‘int [1]’ for(int i = 0; i < nums.size(); i++){ ^
size_type size() const; Код size_type size() const; Return size Returns the number of elements in the vector. Что тут непонятного?
Если массив состоит из int или float То можно юзнуть sum(massiv) Например a = [1, 2, 3, 4, 5, 10] print(sum(a)) # Output: 25