“参数"vs“论据" [英] "Parameter" vs "Argument"

查看:28
本文介绍了“参数"vs“论据"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把 parameterargument 弄混了,没有真正注意什么时候使用一个,什么时候使用另一个.

I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other.

你能告诉我吗?

推荐答案

参数是变量,它是方法签名(方法声明)的一部分.参数是调用方法时使用的表达式.

A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method.

考虑以下代码:

void Foo(int i, float f)
{
    // Do things
}

void Bar()
{
    int anInt = 1;
    Foo(anInt, 2.0);
}

这里if是参数,anInt2.0是参数.

Here i and f are the parameters, and anInt and 2.0 are the arguments.

这篇关于“参数"vs“论据"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆