Rosetta Code:Village Pump/C++ edits

Revision as of 20:09, 7 August 2009 by MikeMol (talk | contribs) (My take.)

Would someone who knows C++ better than I do please review the statements made today (2009-08-07) by 86.199.73.222, particularly Creating an Array and User Input - text? (Those I couldn't figure out what to do with. I've made some followup changes to the other pages; please review those as well.) --Kevin Reid 12:08, 7 August 2009 (UTC)

I'd be tempted to throw the non-code parts of those contributions out. Instead of picking holes in what was previously given, they should be contributing the “right” way. (No, I don't follow the ins and outs of the C++ taliban…) —Donal Fellows 13:08, 7 August 2009 (UTC)
I know C++ pretty well, and I don't think his statements are right. I'll correct it as I see fit. --76.91.63.71 19:32, 7 August 2009 (UTC)
If the new[] operator was deprecated, I haven't heard about it. For arrays, the generally accepted way to go about it is to use std::vector. boost::array is another option, if you're willing to bring in a third-party library (And that's not at all inappropriate, as far as Rosetta Code is concerned). There are and always will be scenarios in C++ where new[] is more appropriate. I can think of three different, yet equally valid, approaches for the cin issue, though. Loop through the cin>>string input sequence until a newline is hit, for example. The breakage that was described comes from non-integer values being left in the input buffer after a cin>>int, and there's a fix for that. (I don't remember what it is, though.) Buffer flush fix taken into account, the readline approach and cin>>string+convert to int approaches are just as equally valid, from a correctness standpoint. --Short Circuit 20:09, 7 August 2009 (UTC)