函数签名中的数据类型 [英] Data types in function signature

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

问题描述

根据我的理解,C ++函数签名列出了函数的每个参数的数据类型和名称。但是遇到了只有类型而不是名称的函数签名。例如:

In my understanding a C++ function signature lists the data type and name of each argument of the function. But have come across function signatures with only the type and not name. Eg:

int Fun( float a, int ) {

return ....
}

return .... }


这里只提到了第二个参数的类型。  这意味着什么?我们在哪种情况下实现这样的功能,有人可以给出调用这样一个函数的例子吗?

Here only the type of second argument is mentioned. What does this signify? In which situation do we implement such a function and can someone give an example of calling such a function?

推荐答案

实际上,只需要数据类型。 通常会看到仅使用数据类型声明的函数,而函数定义包含参数名称。 另外,如果函数没有使用该参数,则省略参数
name会使编译器抱怨存在未引用的参数。
Actually, only data types are required.  It is common to see functions declared using only data types while the function definitions contain argument names.  Additionally, if a function does not make use of that parameter then omitting an argument name keeps the compiler from complaining that there is an unreferenced argument .


这篇关于函数签名中的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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