Why does C++ allow unnamed function parameters?
In C++, you can do this: void foo(int /*no name here*/) { // code for foo } Take note that although an int argument would be passed, it is not named. Why would you do that? One reason is to “stub out” a routine. For instance, let’s say that some functionality was removed from an already existing program. Instead of finding all calls of foo and removing them, they can be left in. The effect is to no-op the code. If the function is inline defined, it wouldn’t even generate any code. Of course, this doesn’t depend upon functions with just one argument. For instance, you might have: void bar(int arg1, int arg2, int arg3) { // code for bar, using arg1, arg2 and arg3 } Now let’s say that the functionality of the program changes and that arg2 is no longer needed. Well, obviously you’ll remove the code that uses arg2. But now the problem is that you’ll probably get an “unused identifier” warning from your compiler. To get rid of the warning you could give it a dummy value or use within the fun