【发布时间】:2010-10-21 11:27:15
【问题描述】:
跟进昨晚的回答 - 我希望更多的 cmets 会为我回答这个问题,但没有骰子。
有没有一种方法可以在没有继承的情况下实现这一点,并且不需要下面倒数第二行代码中的繁琐用法,它将值写入cout?
struct A {
enum E {
X, Y, Z
};
};
template <class T>
struct B {
typedef typename T::E E;
};
// basically "import" the A::E enum into B.
int main(void)
{
std::cout << B<A>::E::X << std::endl;
return 0;
}
【问题讨论】:
标签: c++ visual-c++ templates inheritance enums