In the code below, what do the first and second const
mean?
I guess first or second means foo
is constant; the other one means elements of foo
are also constants. Is it true?
static const char * const foo[] = {"开发者_如何学编程bar", "baz"};
It means its an array of const pointers (so you can't change the pointers) to const chars (so you can't change the chars via the pointers). This is a common way of defining fixed strings, such as command names, in an application.
See cdecl:
declare foo as array of const pointer to const char
精彩评论