S
steve yee
g++ can't compile this code:
#include <iostream>
using namespace std;
template <typename T>
class Outer
{
public:
class Base
{
protected:
int m_n;
};
class Derived : public Base
{
public:
Derived(int n)
{
m_n = n; // g++ says m_n undeclared
}
void print()
{
cout << m_n << endl;
}
};
};
int main(int argc, char *argv[])
{
Outer<int>:erived(100).print();
return 0;
}
#include <iostream>
using namespace std;
template <typename T>
class Outer
{
public:
class Base
{
protected:
int m_n;
};
class Derived : public Base
{
public:
Derived(int n)
{
m_n = n; // g++ says m_n undeclared
}
void print()
{
cout << m_n << endl;
}
};
};
int main(int argc, char *argv[])
{
Outer<int>:erived(100).print();
return 0;
}