解释一下这是什么意思,(DATE).后面为什么可以DATE today

C++语言 码拜 8年前 (2016-04-24) 1377次浏览
这是哪的知识解释一下这是什么意思,(DATE).后面为什么可以DATE today
解决方案

20

typedef可以看作type define的缩写,顾名思义就是类型定义,也就是说它只是给已有的类型重新定义了一个方便使用的别名,并没有产生新的数据类型。
此处就是给struct date取了个别名叫做DATE
参考:http://www.2cto.com/kf/201404/296683.html

20

typedef就是定义一个别名
所以DATA 其实就是 结构体date
DATE today就是声明 这个结构体的一个对象变量

20

C primer plus 这本书十四章

10

typedef 是定义结构体的别名,DATE就是struct date的别名,
若today是变量
struct date today;
等同于
DATE  today;

10

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])();”

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明解释一下这是什么意思,(DATE).后面为什么可以DATE today
喜欢 (0)
[1034331897@qq.com]
分享 (0)