参数和参数之间的区别

发布于 2024-09-08 15:05:23 字数 33 浏览 3 评论 0原文

“参数”和“参数”之间有区别吗,或者它们只是同义词?

Is there a difference between a "parameter" and an "argument", or are they simply synonyms?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

如日中天 2024-09-15 15:05:24

参数通常在实际参数形式参数的意义上使用。

形式参数是在函数声明/定义/中给出的内容原型,而实际参数是调用函数时传递的内容 - 如果您愿意的话,可以是形式参数的实例。

话虽如此,它们通常可以互换使用,它们的确切用途取决于不同的编程语言及其社区。例如,我也听说过实际参数等。

所以这里,xy将是形式参数:

int foo(int x, int y) {
    ...
}

而这里,在函数调用中、 5 和 z 是实际参数:

foo(5, z);

Argument is often used in the sense of actual argument vs. formal parameter.

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.

So here, x and y would be formal parameters:

int foo(int x, int y) {
    ...
}

Whereas here, in the function call, 5 and z are the actual arguments:

foo(5, z);
烟沫凡尘 2024-09-15 15:05:24

一般来说,参数是函数内部使用的参数,参数是调用函数时传递的值。 (除非您采取相反的观点 - 维基百科在讨论参数和参数时提到了替代约定)。

double sqrt(double x)
{
    ...
    return x;
}

void other(void)
{
     double two = sqrt(2.0);
}

在我的论文中,x 是 sqrt() 的参数,2.0 是参数。

这些术语经常至少在某种程度上可以互换使用。

Generally, the parameters are what are used inside the function and the arguments are the values passed when the function is called. (Unless you take the opposite view — Wikipedia mentions alternative conventions when discussing parameters and arguments).

double sqrt(double x)
{
    ...
    return x;
}

void other(void)
{
     double two = sqrt(2.0);
}

Under my thesis, x is the parameter to sqrt() and 2.0 is the argument.

The terms are often used at least somewhat interchangeably.

郁金香雨 2024-09-15 15:05:24

它们在文本中经常互换使用,但在大多数标准中,区别在于参数是传递给函数的表达式,其中参数是函数声明中声明的引用。

They are often used interchangeably in text, but in most standards the distinction is that an argument is an expression passed to a function, where a parameter is a reference declared in a function declaration.

一萌ing 2024-09-15 15:05:24

参数和参数不同
因为参数在程序中使用不同的值并且
参数传递相同的值
在程序中,因此它们在 C++ 中使用。
但c没有区别。 c 中的参数和参数是相同的。

Arguments and parameters are different
in that parameters are used to different values in the program and
The arguments are passed the same value
in the program so they are used in c++.
But no difference in c. It is the same for arguments and parameters in c.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文