M
Mark P
The following code upsets one of my compilers (Sun CC). It reports that
Q is not defined at line 12. It doesn't seem to like that I've renamed
the template formal parameter from T to Q, because it will compile if I
change line 12 to: T q;
So my question is: Is the following legal?
Thanks,
Mark
// code
template <typename T>
struct A
{
template <typename Z>
void foo (Z z);
};
template <typename Q>
template <typename Z>
void A<Q>::foo (Z z)
{
Q q; // line 12
}
int main ()
{
A<int> a;
a.foo(1);
}
Q is not defined at line 12. It doesn't seem to like that I've renamed
the template formal parameter from T to Q, because it will compile if I
change line 12 to: T q;
So my question is: Is the following legal?
Thanks,
Mark
// code
template <typename T>
struct A
{
template <typename Z>
void foo (Z z);
};
template <typename Q>
template <typename Z>
void A<Q>::foo (Z z)
{
Q q; // line 12
}
int main ()
{
A<int> a;
a.foo(1);
}