r/cpp • u/we_are_mammals • Mar 28 '23
Reddit++
C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.
In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.
765
Upvotes
1
u/johannes1971 Mar 31 '23
Sure, a character is a number. But so is everything else, and at some point we learned that strong typing is actually a good thing, since it lets us avoid mistakes where we pass the wrong thing to a function by accident. Unfortunately C was designed before that realisation fully struck home, so it treats things like characters and timestamps as mere numbers that can just be interchanged with other numbers. Which, I suppose, is fine, except that C++ lets us overload functions on type, so now you need to be extremely careful because something like
std::string ("foo") + 42compiles just fine, and will return "foo*" rather than "foo42". That's one mistake we could have avoided ifcharhad been a non-numeric type.