Remix.run Logo
▲ JdeBP a day ago

"You could write it completely differently." is just a more general case of "You could write it in Rust instead.". And it's missing the point.

The point being made is that the stumbling blocks exist to be tripped over by the unsuspecting, and are not because of C.

▲trealira 12 hours ago | parent [-]

They admitted it was a trick question. I just don't think it would have been written as they wrote it by anyone who knew C++ to a decent level in the first place. Maybe that makes it a stumbling block as you're learning it, but it seems obvious to do the simplest thing first, at least in my view.

(Also, this is at least in part inherited from C. Dangling pointers themselves are due to C. And temporary expressions are just acting consistently with C semantics here.)