札记

来源:互联网 发布:淘宝开店新规 编辑:程序博客网 时间:2024/05/02 03:04

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 increasesportability, between versions of Windows, of code that uses the Win32 API.

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