'Difference between terminology : element vs member (of array)?
In the realm of computer science, is there a difference between element of the array vs member of the array? Is it interchangeable to a point the "correct" term is subject to each language's specification? Or do they each have different meaning? Is one correct/wrong?
I was taught myArray[1] is expressed as "second element of the array". But I have read/heard phrases similar to "member of the array". Reading the C Standards gave me the impression that arrays have "elements" and structs/unions have "members" more often. But then I did find the term "flexible array member" in the Standard too, so I got puzzled.
Practically in our workplace it may or may not make a difference and I wouldn't really mind if someone used the wrong term, but for this question I'm seeking the correct answer for a reason.
Solution 1:[1]
The official terminology reference is the ISO C Standard. It uses elements for arrays, and members for structs and unions. So should everybody else to avoid confusion.
The "flexible array member" actually refers to a struct member that has array type. This is an example taken from the C11 Standard, section 6.7.2.1
struct s { int n; double d[]; };
Here, d is the flexible array member. The flexible array in turn has elements of its own (the number of which is not known yet, so the array is incomplete, which is why it's called flexible).
Solution 2:[2]
In my mind, a structure has members (which can be of different types) and an array has elements (which are all of the same type).
Maybe this is because a member is a named object, whereas an element is a positional object. The lines might be blurred a bit for some data structures.
Sometimes an array is used in lieu of a structure and one might refer to the elements as members, as they represent something specific that is not expressed programmatically but only in the mind of the programmer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | John Alexiou |
