札记

1. string a,b,c; 

a=a+b; //error!

a+=b; //OK!


2011-11-03

话题1. 下面这段节选与《Win32多线程程序设计》 

Critical section并不是核心对象,因此没有所谓的handle这样的东西,它和核心对象不同,它存在于进程的内存空间中,不需要像Create这样的API函数获得一个 critical section handle, 你应该做的是一个类型为CRITICAL_SECTION的局部变量初始化,方法是调用InitializeCriticalSection():

由上面三个关键字看出来了一个结论:handle是一个核心对象,并且要用create之类的API才能生成。

由于对handle的好奇,我搜索出以下内容:

HANDLEs are intentionally opaque representations that provide encapsulation and abstraction from internal Win32 resources. This way, the Win32 APIs could potentially change the underlying type behind a HANDLE, without it impacting user code in any way (at least that's the idea).

The handles in these example are really just a new, presumably friendlier, name for void *, which is exactly what a HANDLE is in the Win32 API (look it up at MSDN). It provides an opaque wall between the user code and the Win32 library's internal representations that increases portability, between versions of Windows, of code that uses the Win32 API.

由此我想到了strategy,它把不同的算法用统一的接口封装。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值