Hi,
the following templated code doesn't compile. It gives the error:
template_it.cc: 17: error: type 'std::vector<De rived1<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_TYPEclass Base
{
int id;
};
template <class Tclass Derived1: public Base<T>
{
};
template <class Tclass Derived2: public Base<T>
{
vector<Derived1 <T>*v;
vector<Derived1 <T>*>::iterat or vi;
};
int main()
{
return 0;
}
the following templated code doesn't compile. It gives the error:
template_it.cc: 17: error: type 'std::vector<De rived1<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_TYPEclass Base
{
int id;
};
template <class Tclass Derived1: public Base<T>
{
};
template <class Tclass Derived2: public Base<T>
{
vector<Derived1 <T>*v;
vector<Derived1 <T>*>::iterat or vi;
};
int main()
{
return 0;
}
Comment