现在的位置: 首页 > 综合 > 正文

typedef和typeof

2013年10月06日 ⁄ 综合 ⁄ 共 253字 ⁄ 字号 评论关闭

    typedef用来定义类型别名,c/c++里都有,属于语言的一个特性,和mfc无关
比如
typedef int* intptr;
intptr a; // 相当于int* a;

typeof,我所知道的是gcc中对c/c++语法的一个扩展,用来静态获取参数类型
比如
int a = 3;
typeof(a) b = 4; // 相当于 int b = 4;
typeof("12345") c = "abcde"; // 相当于 const char c[6] = "abcde"
vector<typeof(1.234)> a; // 相当于 vector<double> a;

抱歉!评论已关闭.