gcc又丢脸了
以下程序,是在一个内部类中使用继承于父类的成员,
用VC6编译通过,用g++3.4.2报错:
cctest.cc|19| error: `m_n' undeclared (first use this function)
#include <iostream>
using namespace std;
template < typename T> // 这行去掉的话g++可以编译
class Outer
{
public:
class Base
{
protected:
int m_n;
};
class Derived : public Base
{
public:
Derived( int n )
{
m_n = n; // 将m_n改为 Base::m_n可以编译
}
void print() {
cout << m_n << endl;
}
};
};
int main()
{
Outer<int>::Derived(100).print();
return 0;
}
===================
唉,gcc这里又比较土了,矮人一头了!有没有人遇到类似问题的?