Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'array' is not a member of 'std' [closed]

Tags:

c++

stdvector

I've been looking for a resolution of this error for a while without success. There are a few answer to this topic and they did not help me at all. I am compiling on Linux Mint using codeblocks 12.11 a simple C++ program and I encountered error: 'array' is not a member of 'std'

Some other answers suggested to check the Compiler Setting in: Settings -> Compiler -> Compiler settings -> Compiler Flags, and I thought the case: Have g++ follow the C++11 ISO C++ language standard [-std=c++11]. I still have the same error. Anybody can help?

like image 536
dario Avatar asked Aug 31 '14 16:08

dario


People also ask

What is std array?

std::array is a container that encapsulates fixed size arrays. This container is an aggregate type with the same semantics as a struct holding a C-style array T[N] as its only non-static data member. Unlike a C-style array, it doesn't decay to T* automatically.

How to initialize std:: array in c++?

Initialization of std::array Like arrays, we initialize an std::array by simply assigning it values at the time of declaration. For example, we will initialize an integer type std::array named 'n' of length 5 as shown below; std::array<int, 5> n = {1, 2, 3, 4, 5};

How to declare std array?

We can initialize std::array in two common ways. One method is to simply assign values to the array during declaration. For example, std::array<int, 3> intArray = {1, 3, 5}; initializes an integer type std::array with the name “intArray” of length three.

How to declare array in c++ stl?

The general syntax of declaring an array container is: array<object_type, size> array_name; The above declaration creates an array container 'array_name' with size 'size' and with objects of type 'object_type'.


2 Answers

You just need to include header <array>

#include <array>

If the compiler does not support std::array then in this case it will issue an error that this header is not found.

like image 177
Vlad from Moscow Avatar answered Sep 28 '22 01:09

Vlad from Moscow


You need to use the C++ 11 compiler flag:

-std=c++0x or -std=c++11

like image 23
Vishal Chaudhary Avatar answered Sep 28 '22 02:09

Vishal Chaudhary