如题,谢谢!
解决方案 »
- [求助]关于COM的套间概念适用的场合和对象
- 如何模拟键盘向RichEdit输入中文
- CAsyncSocket TCP协议通信速度慢的问题请教
- 计算中间含有 0x00 的字符串长度
- 用MSCOMM控件接收数据出现的问题
- 不是 视图/文档 的应用!!!
- 做串口通信,VC是不是比Delphi好用?
- 在多文档MDI应用程序中,怎样防止最后一个文档被关闭?
- CreateEx 创建窗口老出错!各位帮我看看 谢谢
- 有谁能帮我的忙?给MaskEditBox增加一个得到焦点和失去焦点的事件?
- www.csdn.com.cn已经开通~目前正在测试阶段~!!
- 1000可用分捐赠,现在可用分少于50的朋友进来,前五位各200分(今晚结帖)
{
void DoWork()
{
//do something
//then
//(might need critical section to guard against concurrent uses)
//or use thread-safe increment function
g_value++; //side effect
} void IncrmentGlobalVariableGValue()
{
//might need critical section to guard against concurrent uses
//or use thread-safe increment function
g_value++;
}
}in this case, DoWork() 有副作用, because people are calling your method, if you don't document it (and most of time, the function is in a cpp body file and they don't get to see it), they didn't know it could change a global variable, which is something irrelevant to your class, this could surprise your callerbut IncrmentGlobalVariableGValue() is a little different, because the caller knows what your method is doing