Chinaunix首页 | 论坛 | 博客
  • 博客访问: 815659
  • 博文数量: 321
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 936
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-23 11:25
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(10)

2015年(61)

2014年(187)

2013年(62)

分类: C/C++

2014-06-24 16:43:50

原文地址:what is typedef? 作者:hnrainll

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])(); "
阅读(348) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~