标题:想发个帖子,问问关于全局变量的看法
只看楼主
醉生梦死
Rank: 1
等 级:新手上路
帖 子:77
专家分:0
注 册:2007-8-21
 问题点数:0 回复次数:2 
想发个帖子,问问关于全局变量的看法
想问问常编程的人,对于全局变量一般在什么情况用,或者说什么样的变量定义为全局变量最合适,大家讨论一下,我吸收点,谢谢
搜索更多相关主题的帖子: 全局变量 看法 帖子 定义 什么样 
2007-08-25 19:47
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
得分:0 
习惯,经验

写多了就有自己的见解了。

Fight  to win  or  die...
2007-08-26 02:27
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
得分:0 
We normally restrain us from using any global variables, since we want to make each module as independent from other modules as possible.

However, when you are studying programming you can use globals.

Globals have two drawbacks:

1. Any function can modify it;
2. In multi-threading programming, you don't know which thread modifies the value so that you have to use mutex, lock/unlock, etc. This complicates the situation.




I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-08-26 07:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-165409-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.072903 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved