Не используйте CVS!! Если Вы хотите модель CVS, Подрывная деятельность является намного лучшей альтернативой.
A typedef-name denotes a type, and not a sequence of tokens (as does a macro). In your case, LPVOID
denotes the type also denoted by the token sequence void *
. So the diagram looks like
// [...] is the type entity, which we cannot express directly.
LPVOID => [void *]
Semantically if you specify the type const LPVOID
, you get the following diagram (the brackets around the specifiers mean "the type denoted by the specifier"):
// equivalent (think of "const [int]" and "[int] const"):
const LPVOID <=> LPVOID const => const [void *] <=> [void *] const
=> ["const qualified void-pointer"]
It's not the same thing as the token sequence const void *
- because this one would not denote a const qualified pointer type, but rather a pointer to a const qualified type (the thing pointed to would be const).
Syntactically a parameter declaration has the following (simplified) form:
declaration-specifiers declarator
The declaration-specifiers in case of const void *p
are const void
- so the base-type of *p
is a const qualified void
, but the pointer itself is not qualified. In case of const LPVOID p
however the declaration-specifiers specify a const qualified LPVOID
- which means the pointer type itself is qualified, making the parameter declaration identical to void *const p
.
Эти ссылки содержат некоторую информацию, которая упрощает понимание typedef лучше:
http://www.velocityreviews.com/forums/t289888-need-clarification -on-typedef-keyword.html http://www.codeproject.com/KB/cpp/complex_declarations.aspx#typedef
LPVOID - далеко общий указатель, который уже давно совпадает с обычным универсальным указателем (на старых 16-битных платформах он был другим).
void* const x = 0;
x = 0; // this line will not compile - u cannot change x, only what it points to
x->NonConstMethod(); // will compile
const void* y = 0;
y = 0; // this line will compile - u can change y, but not what it points to
y->NonConstMethod(); // will not compile
const void* const z = 0; // u cannot change z or what it points to
// btw, the type of the 'this' pointer is "ClassName* const this;"