为什么一个函数没有一个静态的参数? [英] Why can a function not have a Static parameter?

查看:111
本文介绍了为什么一个函数没有一个静态的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是在C code。

The following is the code in c.

     fact(2);
     void fact(static int i)
     {..}

输出:错误不能有静态的参数结果
  那么,为什么我们不能有静态的参数在函数?

Output:Error cannot have static arguments
So why can't we have static arguments in a function?

推荐答案

static关键字意味着一个变量只能有且只有一个在其范围内的实例,该实例是看不见其范围。这些都不要求有意义函数参数:它可以被称为多次,在不同的内存地址,因为它意味着通信,它必须是外部世界可见

The static keyword means that a variable may have only and exactly one instance in its scope, and that instance is invisible out of its scope. Neither of these requirements make sense for a function argument: it may be called multiple times, at a different memory address, and as it's meant for communication, it has to be visible to the outer world.

这篇关于为什么一个函数没有一个静态的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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