Keyword typedef

typedef

typedef type-declaration synonym ;

The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition.

A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types.

Example

//  Example of the typedef keyword
typedef unsigned  long   ulong ;

ulong  ul;      //  Equivalent to "unsigned long ul;"

typedef 
struct  mystructtag
{
   
int    i;
   
float  f;
   
char   c;
}
 mystruct;

mystruct ms;   
//  Equivalent to "struct mystructtag ms;"

typedef 
int  ( * funcptr)();   //  funcptr is synonym for "pointer
                           
//     to function returning int"

funcptr table[
10 ];    //  Equivalent to "int (*table[10])();"

posted on 2006-12-10 23:08 bullGao 阅读(264) 评论(2)  编辑 收藏 引用 所属分类: C++ programming

评论

# re: Keyword typedef 2006-12-11 21:32 Dain

好怪的代码  回复  更多评论   

# re: Keyword typedef 2006-12-11 22:10 GZ

这下好了@Dain
  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2006年12月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

留言簿(1)

随笔分类

随笔档案

收藏夹

搜索

最新评论