札记

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,它把不同的算法用统一的接口封装。


阅读更多
个人分类: c++
上一篇python and pattern
下一篇questions from inter
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭