I'm writing a btree implementation class 'btree' inside a file btree.h and implemented inside btree.tem with an external iterator class 'btree_iterator' in a file btree_iterator.h implemented in a file btree_iterator.tem
Here is the (stripped down) content of btree.h:
#include "btree_iterator.h"
template <typename T> class btree
{
public:
friend class btree_iterator<T>;
typedef btree_iterator<T> iterator;
iterator find(const T& elem);
};
#include "btree.tem"
Now in implementing the find function, I have the following stub implementation in btree.tem:
template <typename T> iterator btree<T>::find(const T& elem) //LINE 24
{
return NULL;
}
(I've only included lines of code that are relevant to my question)
When I compile I get the following errors:
btree.tem:24: error: expected constructor, destructor, or type conversion before 'btree'
Now I know that this has something to do with the fact that I've declared the typedef for iterator inside the class declaration and is therefore scoped only inside that block. But I've tried to put another line of typedef in btree.tem but it just won't work.
How should it be written?