Today, Vikram Ojha asked via email:
I was just thinking why we removed “int” as default return type from C++ which was there in our traditional C type. Why we made such changes, is it to make language more safer?
Short answer: Because it’s ‘inherently dangerous’ in the words of the C committee.
For C++, see D&E (The Design and Evolution of C++) index “implicit int” which takes you to section 2.8.1. For C, see the C99 Rationale section 6.7.2 — interestingly, you can’t search for “implicit int” because that term isn’t used — this is where the string to search for is “inherent danger” :).
Cribbing from Bjarne’s writeup, “implicit int” was removed some 20 years ago for several reasons, including code clarity and in additional avoiding special cases, to simplify C++ code and/or the C++ grammar.
For example, what does this mean?
void f(const T);
In modern C++, it can mean only that f has a const parameter of type T that is unnamed.
If we had implicit int, this would be less obvious: Could it also be a const parameter of type int named T?
There are a number of other cases where just omitting the type, with the meaning that it’s a certain fixed type, makes the grammar and/or the program harder to think about than it should be. So the ability to do that was removed in both C and C++.