不定参数实际为数组参数的一种写法而已,本质上与数组参数完全相同 //1.数组参数函数 public static int sum(int[] values) { } //2.不定参数函数 不定参数只能是,形参的最后一个参数 public static int sum(int... values) } // 3. 不定参数直接当做数组来使用 private static int sum(int... values) { int sum = 0; for (int i = 0; i < values
google一下 c overiding发现有这样一段英文解释: Because C doesn't require that you pass all parameters to the function if you leave the parameter list blank in the prototype. The compiler should only throw up warnings if the prototype has a non-empty parameter list
一.可变参数函数实现原理 C函数调用的栈结构: 可变参数函数的实现与函数调用的栈结构密切相关,正常情况下C的函数参数入栈规则为__stdcall, 它是从右到左的,即函数中的最右边的参数最先入栈. 本文地址:http://www.cnblogs.com/archimedes/p/variable-parameter.html,转载请注明源地址. 例如,对于函数: void fun(int a, int b, int c) { int d; ... } 其栈结构为 0x1ffc-->d 0x200