I know that minimum number of parameters in function definition is zero, but what is the maximum number of parameters in function definition? I am asking the question just f
As previous answerers have adequately noted, the number of parameters depends on the C++ compiler. The compiler limit may well be due to limitations imposed by hardware environments.
For example the VAX CPU architecture uses an 8-bit field which holds the number of arguments, so compliant VAX code cannot pass more than 255 parameters.
Likewise many small processors like the Intel 8048 family are so constrained for memory that most C and C++ compilers give grief if more about four parameters are used. While many mainstream developers may sneer at the 8048, its descendants remain one of the most widely deployed CPUs—mostly in embedded devices.
Many RISC architecture implementations specify a parameter passing method using registers, rather than the stack. A basic ARM CPU, for example, has only 16 registers. The maximum number of parameters could well depend on compiler command line options which affect how it generates code to pass parameters. Maybe more than eight are pushed onto a stack. Maybe not.
If those examples seem overly restrictive, consider that the Palm OS limited a C function to a single parameter, and that had to be of type int
or void *
.