gpt4 book ai didi

c - 为什么union可以这么用?

转载 作者:太空狗 更新时间:2023-10-29 15:53:16 24 4
gpt4 key购买 nike

不是说union中的成员是排他的吗,如果你已经引用了其中一个就不能再引用另一个了?

union Ptrlist
{
Ptrlist *next;
State *s;
};

void
patch(Ptrlist *l, State *s)
{
Ptrlist *next;

for(; l; l=next){
next = l->next;
l->s = s;
}
}

但是上面同时指的是nexts,谁能解释一下?

最佳答案

union 只定义了那个

&l->next == &l->s 

就是这样。首次访问无语言限制。

关于c - 为什么union可以这么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6998093/

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