什么是空参数列表是什么意思? [英] What does an empty parameter list mean?

查看:625
本文介绍了什么是空参数列表是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我目前的状态看这本书,当你声明C中的函数不接受任何参数,但您不使用关键字void函数调用可以传递任何
它希望的论点。所以我尝试这一点。

The book that i am currently reading states that when you declare a function in c that accepts no arguments, but you do not use the keyword void "the function call can pass any arguments it wants". so i attempted this.

int number();

int main(void)
{
    int x =1;
    printf("%d",number(x));
}

int number()
{
    return x;
}

但它没有编制?请问这是怎么工作的?

but it did not compile??? how does this work?

推荐答案

这是一个过时的功能 1 从之前C组标准化的,几十年前。

This is an obsolescent feature1 from before C was standardized, decades ago.

不要使用它。

在古代C,十年在你出生前,你可以声明一个不带参数的功能。当你把它称为,编译器将促进参数的缺省类型,并将它们传递给函数。从本质上讲,编译器在调用的参数计算出该参数的声明。

In ancient C, a decade before you were born, you could declare a function with no parameters. When you called it, the compiler would promote the parameters to default types and pass them to the function. Essentially, the compiler figured out the parameter declarations from the arguments in the call.

该功能应该还是确定与参数,并应符合函数的调用方式。

The function should still be defined with parameters, and they should match the way the function is called.

1 功能是错误的单词。这是事情的时候进行,因为更好的方法还没有被广泛的发展方式。在一个新的编程语言,该特性将被视为缺乏。

1 "Feature" is the wrong word. It was the way things were done at the time, since better ways were not yet widely developed. In a new programming language, this characteristic would be considered a deficiency.

这篇关于什么是空参数列表是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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