While vector is a really useful container, and there are certainly
lots of cases where OP should use it, it's not the answer to every
question ever,
You're right, it isn't, but the C++ community doesn't promote the use of std::vector
because it's their favorite container ever (it's Stephan T. Lavavej's though) but because it is the superior alternative to whatever crappy code the OP has written. Yes, the code in the specific question was a typo (and it should be closed as such), but he has learned nothing from the exercise. If there's anything the OP is to learn, it's that he should stop what he's doing and adopt more useful practices. To quote an unattributed Chinese proverb:
Give a man a fish and you feed him for a day. Teach a man to fish and
you feed him for a lifetime.
For a blog post on the matter, see Alex Papadimoulis's article entitled "Pounding A Nail: Old Shoe or Glass Bottle?".
Note that the user's comment you're referring to doesn't just blindly say use std::vector
, he offers a reasonable justification:
Use a vector of vectors or a specialized matrix. Your class doesn't
behave properly. Those would make it behave properly and let you get
rid of your destructor to boot.
Therefore it isn't just noise, it actually contains useful information.
A user I really like is Basile Starynkevitch because he seems to have mastered the ability of turning boilerplate comments (i.e., "use a debugger") into helpful information. See his comments page and his highest voted answer. All around, it gives good advice. Enable warnings, become familiar with widely-used build systems, learn how to use a debugger, and so on. We could say "that doesn't answer the question, it's just noise" but then the OP will just continue to write crappy code and learn nothing.