Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 4
    New is relative, as it was already in the 2011 standard. Also, the second demo is obviously not C++. Commented Aug 10, 2018 at 16:30
  • An alternate solution if you want to use a single exit point would be to set a flag longerLength = true, then return longerLength. Commented Aug 10, 2018 at 17:48
  • @Deduplicator Why isn't the second demo C++? I don't see why not or am I missing something obvious? Commented Aug 10, 2018 at 18:59
  • 2
    @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. Commented Aug 10, 2018 at 19:14
  • @IllusiveBrian: sizeof would be in bytes... The most generic since C++17 is std::size(). Commented Aug 10, 2018 at 19:51