Hi everyone,
Can anybody explain why this won't build and what the error is? The error is with the list iterator in the TestClass class. Basically, I have a two templated classes, Item and TestClass. TestClass uses Item to define on of its template parameters.
The build error using g++ 4.2.3 is:
test.C:33: error: type ‘std::list<Entr y, std::allocator< _Tp> >’ is not derived from type ‘TestClass <Key, Element, Entry>’
test.C:33: error: expected ‘;’ before ‘myIter’
I can't figure this one out. Many thanks.
-David
Can anybody explain why this won't build and what the error is? The error is with the list iterator in the TestClass class. Basically, I have a two templated classes, Item and TestClass. TestClass uses Item to define on of its template parameters.
Code:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include "test.h"
using std::vector;
using std::string;
using std::list;
template<class Key, class Element>
class Item
{
private:
Key _key;
Element _element;
};
template<class Key, class Element, class Entry=Item<Key,Element> >
class TestClass
{
private:
list<Entry>::iterator myIter;
};
int main(int argc, char *argv[])
{
vector< list<TestClass<string, int> > > _v;
list<TestClass<string, int> >::iterator _it;
return 0;
}
test.C:33: error: type ‘std::list<Entr y, std::allocator< _Tp> >’ is not derived from type ‘TestClass <Key, Element, Entry>’
test.C:33: error: expected ‘;’ before ‘myIter’
I can't figure this one out. Many thanks.
-David
Comment