静态函数和变量用C [英] Static functions and variables in C

查看:180
本文介绍了静态函数和变量用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道什么是使用面向对象语言的静态变量,不过,我不明白什么是C.使用静态关键字的含义的目的
有人可以解释给我吗?

I know what is the purpose of using static variables in an object oriented language, still, I don't understand what is the meaning of using the "static" keyword in C. Can someone explain it to me?

推荐答案

在函数或全局变量,静态使得函数或全局变量本地到该文件;其他文件无法通过该名称访问该功能或全局变量(但如果你给一个指向它拿走他们可以访问它)。

On a function or global variable, static makes the function or global variable local to that file; other files cannot access that function or global variable by that name (but they can access it if you give a pointer to it away).

在一个局部变量,它使充当如果它是一个全局变量,但仅仅是函数内部访问(除非再次,你给它的指针距离)。

On a local variable, it makes it act as if it was a global variable, but is only accessible within that function (unless, again, you give a pointer to it away).

这篇关于静态函数和变量用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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