开发者

Unusual typedef use in C++

开发者 https://www.devze.com 2023-04-06 01:01 出处:网络
I came 开发者_如何学Cacross a new use of the keyword typedef in C++. What does this typedef statement mean ?

I came 开发者_如何学Cacross a new use of the keyword typedef in C++.

What does this typedef statement mean ?

int typedef foo;


It's the same as

typedef int foo;

i.e. it defines foo to be the type int. While the grammar allows to swap typedef and int in this case, you usually would not do this because it impairs readability.


typedef is a decl-specifier, so it has the same syntax rules as const or static. It can be moved about like that and will mean the same thing.

0

精彩评论

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