I'm a noob experimenting with templates and design patterns and would like to create an iterator pattern using a template argument ITEM. However, my private member var is a STL container that is itself a template, so how can I 'sync' the template argument of the STL container to that used by the class template?
Here is the actual class:
#include "StatusIteratorInterface.h"
#include "StatusContainer.h"
#include <map>
template<typename ITEM> class StatusContainer;
template <typename ITEM>
class StatusIterator : public StatusIteratorInterface<ITEM> {
public:
StatusIterator( StatusContainer<ITEM>* container );
ITEM* getFirst( void );
ITEM* getNext( void );
bool isDone( void );
ITEM* getCurrent( void );
private:
StatusContainer<ITEM>* container_;
ITEM* currentItem_;
std::multimap< std::pair<std::string, uint32_t>, ITEM >::iterator conIter1_; //gives error
std::multimap< std::pair<string, uint32_t>, uint32_t>::iterator conIter_;
};
conIter_ is fine, but 'hard-codes' my template value. including the line above it gives this compile error:
/Users/joe/Developer/Template_DesignPattern_Iterator/StatusIterator.h:33: error: expected ';' before 'conIter1_'
I have a main that compiles and runs this code fine, but obviously is only suitable for uint32_t types. Pardon me if I've used incorrect terminology such as 'template argument' vice 'template parameter'.