In answering the question pointer array of structure I was reminded of a couple of other questions.
A solution to the sorting 1 million 8 digit numbers in 1 MB of RAM requires a deep understanding of data structures and their representations. As a community, we continually discourage the use of the raw C heritage of the C++ language.
I feel we are splitting the language into the user language - with containers and std::string
s, shared_ptr
for the masses, and a leaving the ability to understand the underlying memory layout of things, and the ability to answer the sort 1 million things question in C++ to a significantly smaller set of library writers.
I think it is correct for us to guide people into using these high quality features of the C++ language, but we should not be downvoting people for using the more basic language, so we continue to get a vibrant new set of people who can help maintain and enhance the C++ language.
Should the C++ tag limit questions and answers applicable coding styles allowed by the standard library since C++11?
Is downvoting a question/answer because it describes memory layouts, or uses new/delete the mechanism we agree upon to shape the answers on Stack Overflow?
Using a std::string
for a struct of name/number would be inefficient if millions were being stored.
Using a fixed array for strings of wildly different lengths would also be inefficient.