菜鸟问题

沧海桑人 2004-10-17 06:07:21
函数前面加static是什么意思?为什么要加?
...全文
86 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
icecools 2004-10-17
  • 打赏
  • 举报
回复
如果在类里有个static的变量,那么只有static的函数可以访问这个变量
ywfscu 2004-10-17
  • 打赏
  • 举报
回复
函数前加static表示该函数只能在本编译单元(就是本文件)内用,不像其他函数是全局域的。
yoyo82 2004-10-17
  • 打赏
  • 举报
回复
static指静态的意思.
C也是一样的啊!
它表示变量在程序整个过程中不会消失,只有程序结束才释放它。
你自己去搜索一下,很多这方面的资料。
沧海桑人 2004-10-17
  • 打赏
  • 举报
回复
这些我都知到,我问的是函数前面为什么要加它(我用的是C不是C++);
fanxin6619 2004-10-17
  • 打赏
  • 举报
回复
靠:
你可是比我还菜拉。兄弟,同病相怜拉
kobefly 2004-10-17
  • 打赏
  • 举报
回复
静态变量
Squall1009 2004-10-17
  • 打赏
  • 举报
回复
static指静态的意思.
http://community.csdn.net/Expert/TopicView3.asp?id=3365750
insulator 2004-10-17
  • 打赏
  • 举报
回复
表示静态的意思啊
可以加在变量前,
it is allocated when the program begins and deallocated when the program ends;and initializes it to 0 unless another value is specified.

In C++, when modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all the instances of the class.
加在函数前
When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members.

最基本的理解是,对于一个全局静态变量,你对它作的改变它都记录着

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧