S
soft wind
I have a compile error in my code:
-------------------------------------------------
#include <vector>
template < typename T >
class Foo {
public:
typedef std::vector< T >::iterator iterator; // (1)error (I
want to fix this)
// typedef std::vector< typename T >::iterator iterator; // (2)
still error
typedef T::const_iterator const_iterator; // (3) error
// typedef typename T::const_iterator const_iterator; // (4)OK
private:
std::vector< T > vec_m;
};
int main( void )
{
return 0;
}
-------------------------------------------------
Compiler : gcc version 4.0.1
Error message : type 'std::vector<T, std::allocator<_CharT> >' is not
derived from type 'Foo<T>'
In case of "T::const_iterator "(3) , I can fix it by adding
"typename" (4)
but similar way to fix is not effective for (1).
How can I fix (1) ?
Thanks,
Tsunehiko
-------------------------------------------------
#include <vector>
template < typename T >
class Foo {
public:
typedef std::vector< T >::iterator iterator; // (1)error (I
want to fix this)
// typedef std::vector< typename T >::iterator iterator; // (2)
still error
typedef T::const_iterator const_iterator; // (3) error
// typedef typename T::const_iterator const_iterator; // (4)OK
private:
std::vector< T > vec_m;
};
int main( void )
{
return 0;
}
-------------------------------------------------
Compiler : gcc version 4.0.1
Error message : type 'std::vector<T, std::allocator<_CharT> >' is not
derived from type 'Foo<T>'
In case of "T::const_iterator "(3) , I can fix it by adding
"typename" (4)
but similar way to fix is not effective for (1).
How can I fix (1) ?
Thanks,
Tsunehiko