To remove these ++
and --
operators from C and/or C++ would certainly break A LOT of code - in fact I suspect, if you remove those two operators, just about every single existing source file will stop compiling.
They are very useful when used correctly - as long as you don't use it on both sides of the same variable, you'll be fine.
This code won't compile, but adding parenthesis to make it (++n)++
does compile correctly - but g++ gives a warning "operation on ‘n’ may be undefined".
And if we remove the ++
and --
operator, how do you expect to write a common for-lopp:
for(int i = 0; i < 100; i++)
like this:
for(int i = 0; i < 100; i = i + 1)
or
for(int i = 0; i < 100; i += 1)
Banning everything that can be misused in C and C++ would pretty much reduce the language to nothing - and certainly either make the language completely useless or at least prevent a lot of valid uses. It'd be like banning knifes, because people CAN use them (and indeed have used them) for bad things. But if you want to cut bread, meat or vegetables, they do make darn handy tools for that purpose.