Skip to main content
10 events
when toggle format what by license comment
Aug 11, 2018 at 23:38 comment added Lewis Pringle @DavidHammend the constraints on programming - the tools languages etc, and the problems expected to solve evolve. My answer was broad enough to be generally applicable in any age (prefer simple over rules). I've gotten lots of downvotes on things I thought were more clear cut. No biggie. Just try to be helpful and give best answer I can. And thx on congrats
Aug 11, 2018 at 23:08 comment added David Hammen Re This is easy. Well, almost. You did get one downvote (not from me). There remain some people whose coding practices harken from a previous millennium and who still think that multiple returns is absolutely anathema.
Aug 11, 2018 at 22:41 comment added David Hammen Congrats on getting the populist badge for this answer.
Aug 10, 2018 at 20:40 comment added Lewis Pringle The code never declared 'array', so we are left to guess. It could easily have been a custom class (not a standard library class) - in which case the example would be perfectly valid (though not perfectly good) C++. It also could be some sort of typo, but this didn't seem central to the question.
Aug 10, 2018 at 19:51 comment added Deduplicator @IllusiveBrian: sizeof would be in bytes... The most generic since C++17 is std::size().
Aug 10, 2018 at 19:14 comment added IllusiveBrian @Rakete1111 Raw arrays don't have any properties like length. If it were actually declared as an array and not a pointer, they could use sizeof, or if it were an std::array, the correct member function is size(), there isn't a length property.
Aug 10, 2018 at 18:59 comment added Rakete1111 @Deduplicator Why isn't the second demo C++? I don't see why not or am I missing something obvious?
Aug 10, 2018 at 17:48 comment added Cullub An alternate solution if you want to use a single exit point would be to set a flag longerLength = true, then return longerLength.
Aug 10, 2018 at 16:30 comment added Deduplicator New is relative, as it was already in the 2011 standard. Also, the second demo is obviously not C++.
Aug 10, 2018 at 15:31 history answered Lewis Pringle CC BY-SA 4.0