参数和参数之间的区别 [英] Difference between parameter and argument
问题描述
参数"和参数"之间是否有区别,或者它们只是同义词?
Is there a difference between a "parameter" and an "argument", or are they simply synonyms?
推荐答案
参数通常用于实际参数与形式参数的意义上.
形参是在函数声明/定义/原型中给出的,而实参是调用函数时传递的——a的实例形式参数,如果你愿意的话.
The formal parameter is what is given in the function declaration/definition/prototype, while the actual argument is what is passed when calling the function — an instance of a formal parameter, if you will.
话虽如此,它们通常可以互换使用,它们的确切用途取决于不同的编程语言及其社区.比如我也听说过实参等
That being said, they are often used interchangeably, their exact use depending on different programming languages and their communities. For example, I have also heard actual parameter etc.
所以这里 x
和 y
将是形式参数:
So here, x
and y
would be formal parameters:
int foo(int x, int y) {
...
}
而这里,在函数调用中,5 和 z
是实际参数:
Whereas here, in the function call, 5 and z
are the actual arguments:
foo(5, z);
这篇关于参数和参数之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!