R
Ralf Goertz
Hi,
the following templated code doesn't compile. It gives the error:
template_it.cc:17: error: type 'std::vector<Derived1<T>*,
std::allocator<Derived1<T>*> >' is not derived from type 'Derived2<T>'
template_it.cc:17: error: expected ';' before 'vi'
However, the same code compiles fine when I don't use any templates.
Also, why ist it okay to define (in class Derived2) the vector v but not
okay to define the iterator?
Thanks,
Ralf
#include <vector>
using namespace std;
template <class ID_TYPE> class Base
{
int id;
};
template <class T> class Derived1: public Base<T>
{
};
template <class T> class Derived2: public Base<T>
{
vector<Derived1<T>*> v;
vector<Derived1<T>*>::iterator vi;
};
int main()
{
return 0;
}
the following templated code doesn't compile. It gives the error:
template_it.cc:17: error: type 'std::vector<Derived1<T>*,
std::allocator<Derived1<T>*> >' is not derived from type 'Derived2<T>'
template_it.cc:17: error: expected ';' before 'vi'
However, the same code compiles fine when I don't use any templates.
Also, why ist it okay to define (in class Derived2) the vector v but not
okay to define the iterator?
Thanks,
Ralf
#include <vector>
using namespace std;
template <class ID_TYPE> class Base
{
int id;
};
template <class T> class Derived1: public Base<T>
{
};
template <class T> class Derived2: public Base<T>
{
vector<Derived1<T>*> v;
vector<Derived1<T>*>::iterator vi;
};
int main()
{
return 0;
}