且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以在编译时检测函数的默认参数?

更新时间:2023-09-24 17:39:52

否,在编译时无法检测默认参数。

No you can't detect the default parameter at compile time.

您已声明函数定义中的默认参数。但是默认参数并不链接到函数本身,而是链接在函数调用范围内已知的函数的声明。

You have declared the default parameter within the function definition. But default parameters are not linked to the function itself, but the declaration of the function that is known in the scope where the function is called.

否则,您可能已经知道相同功能的不同默认参数集。

Otherwise stated: you could have different sets of default parameters for the same function.