Reputation: 2340
While using "array" as an identifier Codeblocks highlighted it like the other keywords. I searched it up in Why is "array" marked as a reserved word in Visual-C++?
But the answers were outdated. If yes, how is it used ?
Upvotes: 0
Views: 1226
Reputation: 45674
No, array is not a keyword.
Still, there is a C++11 standard-library type: std::array
, a fixed-length array container.
Here a list of the keywords from the C++1y draft:
alignas continue friend register true
alignof decltype goto reinterpret_cast try
asm default if return typedef
auto delete inline short typeid
bool do int signed typename
break double long sizeof union
case dynamic_cast mutable static unsigned
catch else namespace static_assert using
char enum new static_cast virtual
char16_t explicit noexcept struct void
char32_t export nullptr switch volatile
class extern operator template wchar_t
const false private this while
constexpr float protected thread_local
const_cast for public throw
These alternative representations (whose very existence I dislike, but that's just me) are not keywords though still reserved:
and and_eq bitand bitor compl not
not_eq or or_eq xor xor_eq
Contextual keywords (override control, put at the end of the function declaration in a class (new
not listed because already a keyword))
final override
Upvotes: 4
Reputation: 23813
C++ Keywords are listed in the C++ standard, section § 2.13.
array
is not listed there, so it isn't.
Note:
std::array
is a standard type, but not a keyword.array
is a valid identifier, but it certainly is discouraged because of the previous point.Upvotes: 3
Reputation: 1
array
is not a keyword, but the C++11 standard defines its STL with a std::array
template container. You should prefer
std::array<int,5> tab;
instead of int tab[5];
because std::array
have interesting functions and works better with other parts of the STL library.
Since it is a standard container, I would advise you to avoid using the array
(or vector
, because of std::vector
, etc...) identifier in your own code (especially in reusable headers), to avoid future potential conflicts with <array>
header, and also for readability reasons. But in principle you could define your own array
but I don't recommend that.
Upvotes: 4
Reputation: 73446
array
is a standard container, as you can see here.
It doesn't belong to the keywords, but it's part of the standard library.
Upvotes: 3