gpt4 book ai didi

c++ - typedef type * type::* ,它是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:37 25 4
gpt4 key购买 nike

我有以下代码:

  struct myType { myType * ptr; };
typedef myType * myType ::* other_type;

第二行typedef'ining是什么?这是一个返回 myType 指针或其他东西的成员函数吗?

最佳答案

other_type 定义为指向 myType 成员的指针,其中所述成员本身是指向 myType 的指针。例如,您可以这样使用它:

other_type x = &myType::ptr;
myType mine;
mine.*x = &mine;

为什么你会这样做,我不能说。

关于c++ - typedef type * type::* ,它是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23083624/

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