What does "C-style array" mean and how does it differ from std::array (C++ style)?
I came across this question, while re开发者_如何学Cading 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:
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.
精彩评论