【发布时间】:2013-08-30 01:21:18
【问题描述】:
我正在学习结构中的结构和 typedef 定义。我理解正常的 typedef 定义,但在这个例子中 typedef 用于结构数据点
struct CGPoint{
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
CGPoint rectPt;
rectPt.x=2;
rectPt.y=3;
我不明白 typedef struct CGPoint CGPoint; 为什么 CGPoint 被列出两次?
【问题讨论】:
-
这可能有助于回答您的问题:stackoverflow.com/questions/612328/… 这不是 Objective-C 特有的,而是与 struct 关键字在 C 中的工作方式有关。