1
此代码不能在GCC编译:
template <typename T>
struct Base
{
public:
int x;
};
template <typename B>
struct Middle : public B
{
};
template <typename T>
struct Sub : public Middle<Base<T> >
{
public:
void F()
{
x=1; // error: ‘x’ was not declared in this scope
}
};
如果任Base
或Sub
没有模板类,它不会抱怨。 VC处理它。
为什么?
[模板继承问题]的副本(http://stackoverflow.com/questions/2982660/problem-with-template-inheritance) – 2010-06-14 21:08:49