gpt4 book ai didi

c - 我无法理解这个简单代码的意义

转载 作者:太空宇宙 更新时间:2023-11-04 00:27:31 24 4
gpt4 key购买 nike

我正在做这个作业,有些东西(来自启动 Material )我无法理解。

typedef enum
{
NORTH,
EAST,
SOUTH,
WEST,
NUM_POINTS
} Point;

typedef Point Course[NUM_POINTS] ;

我不明白最后一行背后的想法,如何在代码中使用它?

最佳答案

typedef a b;

使 b 成为类型 a 的别名,例如

typedef int foo;

int bar;
foo bar;

两个 bar 是等价的。在你的情况下,

typedef Point Course[NUM_POINTS] ;

使 Course 成为类型 Point[NUM_POINTS] 的别名(其中 NUM_POINTS == 4),因此

Course baz;
Point baz[NUM_POINTS];

是等价的。

关于c - 我无法理解这个简单代码的意义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2881937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com