gpt4 book ai didi

c++ - 函数和参数

转载 作者:太空宇宙 更新时间:2023-11-04 15:44:27 25 4
gpt4 key购买 nike

如果我有这样的功能

int mathscalc (int a, int b = 5)
{

}

我调用函数 mathscalc(a),当它需要 2 个参数时我怎么能只做 1 个参数?如果可能的话。

最佳答案

b 有一个默认值。如果不指定,则为5,如果指定,则为给定的值。

例如:

mathscalc(3, 10) // b is 10 inside the function call

mathscalc(3) // b is 5 inside the function call

关于c++ - 函数和参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18740917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com