gpt4 book ai didi

c++ - 在 C++ 中确定成员的类实例

转载 作者:太空狗 更新时间:2023-10-29 23:34:08 25 4
gpt4 key购买 nike

我从来没有在任何语言中看到过这种情况,但我想知道是否可以使用一些我不知道的技巧。

假设我有一个类似的函数

struct A {
// some members and methods ...
some_t t;
// more members ...
};


void test(some_t& x) { // a reference to avoid copying a new some_t
// obtain the A instance if x is the t member of an A
// or throw an error if x is not the t member of an A
...
// do something
}

能否获取成员txA实例?

最佳答案

很遗憾,这是不可能的。

关于c++ - 在 C++ 中确定成员的类实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997753/

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