[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
g++ error : Nested template classes
From: |
BJP |
Subject: |
g++ error : Nested template classes |
Date: |
2 Feb 2005 16:45:01 -0800 |
User-agent: |
G2/0.2 |
Following is my nested template class:
template <class T>
class A
{
public:
typedef std::pair<A,T> Pair;
A();
~A();
bool add( const T& val );
protected:
template <class T> //Line 11: error line
class B
{
T& getvalue();
void setvalue(const T& val);
};
typedef B<T> Node;
private:
....
};
when I try to build using gcc 3.3.2, it gives me error on Line: 11
saying "shadow class T"
Any Idea why, works with Visual Studio C++.
So then I change Line 11 to say "template <class Z>", which worked.
Question is do I have to change all instance of "T" to "Z" in class B
i.e. function getvalue and set value looks like
Z& getvalue()
void setvalue(const Z& val);
or is it ok to keep as it is? i.e.
T& getvalue()
void setvalue(const T& val);
- g++ error : Nested template classes,
BJP <=