C++ array

From Just Solve the File Format Problem
Revision as of 14:48, 13 May 2015 by VolodyA! V Anarhist (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
File Format
Name C++ array
Ontology
Released 1983

C++ array is a way to store a series of data of the same type and purpose, the data then can be accessed by the name of the array and index within it. C++ array index always begins with 0 and goes to the value 1 less than the size of an array.

Index is written within square brackets. This way of indexing data has become so associated with arrays, that many people expect that only arrays can do that. This is not the case, since it is possible to define operator[] for any type.

C++ does not provide safety for dereferencing array elements. It becomes the job of the programmer to track and check that the element really exists within a specific array before trying to do any operations with it. Failing to do so will lead to undefined behaviour.

Dynamic vs static arrays

Static arrays must have a known declaration at compile time, meaning that it is not possible to have a scenario where the application makes the decision about the size of an array during its operation. Static arrays are normally placed inside the stack of the program.

Dynamic arrays are placed within the heap and can have the size that it determined at the run time.

Neither of these, however, can have the size, that changes after it has been declared.

Arrays and pointers

See C++ pointer

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox