一个混乱的typedef涉及类范围 [英] A confusing typedef involves class scope
本文介绍了一个混乱的typedef涉及类范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读C ++项目的代码,它包含以下形式的代码:
I'm reading code of a C++ project and it contains some code of the following form:
namespace ns {
class A {};
class B {};
}
struct C {
typedef ns::A* ns::B::* type;
};
有人可以解释 typedef
线? 类型
似乎是指向 ns :: B
成员的指向 ns :: A
,但我不确定。
Can someone explain the meaning of the typedef
line? type
seems to be some kind of pointer to member of ns::B
which points to ns::A
, but I'm not sure.
类 A
B
在实际代码中不为空,但我认为这里不相关。这是一个实例。
Class A
and B
in the real code are not empty, but I think it's not relevant here. And here is a live example.
推荐答案
ns::B::*
是 B
的指针成员变量。 ns :: A *
是它的类型。
is a pointer-to-member-variable of B
. Then ns::A*
is its type.
所以整个声明意味着
<$> 类型
的
B
的指针成员变量ns :: A *
pointer-to-member-variable of B
of type ns::A*
这篇关于一个混乱的typedef涉及类范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文