5 ms·
This specific question formulation suffers from too vague terminology. If you asked me, I wouldn't even be sure what "C++-style arrays" means. IMHO, the most
by cben 10y ago
This specific question formulation suffers from too vague terminology. If you asked me, I wouldn't even be sure what "C++-style arrays" means. IMHO, the most important part of the (imprecise) answer about "pointer vs std::array" was saying "std::array". Just googling that, immediately gives several results that all talk about "decaying to a pointer".
"Because std::array doesn’t decay to a pointer when passed to a function, the size() function will work even if you call it from within a function:"
That's golden. It doesn't fully explain the C pointer/array differences, but it points out their fundamental problem.
Anyway it's not a good example of question requiring a lot of thinking. It is standard knowledge for people involved with C++, so could be a very effective thing to ask someone more experienced, except it's so basic that googling it I currently get a good SO answer on first place:
https://stackoverflow.com/questions/7129717/what-does-c-style-array-mean-and-how-does-it-differ-from-stdarray-c-style https://stackoverflow.com/questions/7129717/what-does-c-styl...
I strongly disagree only people who read the fine "complete specification" have done their homework.
Yes, interrupting coworkers is problematic and doesn't scale, but stackoverflow does (and IRC etc are not bad).
I adopting Julia's post as my new non-hostile link to how to ask questions.