I came across this question, while reading about std::array and std::vector.
A C-Style array is just a "naked" array - that is, an array that's not wrapped in a class, like this: And a "C++ style array" (the unofficial but popular term) is just what you mention - a wrapper class like std::vector (or std::array ).
What does "C-style array" mean and how does it differ from std::array (C++ style)? Bookmark this question. Show activity on this post. I came across this question, while reading about std::array and std::vector. Show activity on this post. A C-Style array is just a "naked" array - that is, an array that's not wrapped in a class, like this:
A C-style array is nothing more than a block of memory that can be interpreted as an array; it is not a defined data type. Other options are available in class libraries. Arrays must be declared by type and either by size or by some indication of the number of dimensions.
A structure creates a data type that can be used to group items of possibly different types into a single type. Array refers to a collection consisting of elements of homogeneous data type. Structure refers to a collection consisting of elements of heterogeneous data type. Array uses subscripts or “ [ ]” (square bracket) for element access
A C-Style array is just a "naked" array - that is, an array that's not wrapped in a class, like this:
char[] array = {'a', 'b', 'c', '\0'};
Or a pointer if you use it as an array:
Thing* t = new Thing[size];
t[someindex].dosomething();
And a "C++ style array" (the unofficial but popular term) is just what you mention - a wrapper class like std::vector
(or std::array
). That's just a wrapper class (that's really a C-style array underneath) that provides handy capabilities like bounds checking and size information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With