开发者

What does `const char* yes[5]` represents in this line of code?

开发者 https://www.devze.com 2023-03-03 23:35 出处:网络
I hav开发者_JS百科e a question about typedef in c++ for example: typedef const char* yes[5]; Does typedef gives a alternative name of const char*, so the alternative name of const char* is yes[5]?

I hav开发者_JS百科e a question about typedef in c++

for example:

typedef const char* yes[5];

Does typedef gives a alternative name of const char*, so the alternative name of const char* is yes[5]? what does yes[5] here represents? and how to create two yes arrays and initializes one of the two?


No. This declares a type yes which is an array of five const char * .

See this link and type const char *yes[5]; inside the text area.


No, this makes yes a new name for an array of 5 pointers to constant character data.

The way to think of it is the expression after typedef looks like a declaration, and the name in the declaration is instead considered a name for the new type which is the type being declared.

So typedef int x; makes x be a new name for int. This doesn't change with arrays.

0

精彩评论

暂无评论...
验证码 换一张
取 消