I built an iterator class for my container that looks like this
template <typename T>
class binary_tree_iterator {
private:
binary_tree<T>* tree;
public:
...
bool operator!=(const binary_tree_iterator& rhs) const {return tree->data() != rhs.tree->data();}
};
This thing ----------------------^
My best understanding is that I'm passing an instance of my class into another instance of my then class and then accessing a private data member of one within the other. Is this allowed because they are instances of the same class or am I missing something?
Data() just returns data from container.