title: Custom Iterator for Template
body: <p>I am currently trying to build an iterator for a custom class and it's not going particularly well: The problem I'm having is that I my custom class uses a template and looks something like this:</p>
  
  <pre><code>template&lt;class T&gt;
  class MyClass {
  private:
      T memberVar;
  };
  </code></pre>
  
  <p>Now, MyClass is basically a wrapper for memberVar which at the moment is a map or a map of maps. Now, I would like to create an iterator in another class and do useful things with it, i.e. access elements in my map or map of maps.</p>
  
  <p>I have tried forwarding my iterator from my map, which doesn't give me an error in MyClass when I do something like <code>typedef T::iterator iterator;</code>, but it obviously doesn't want to be nice to me when I want to call <code>myIterator-&gt;first</code>, because now it doesn't believe me anymore that this will work. To be honest, I was surprised to see that my typedef actually works.</p>
  
  <p>Now my question: Is there a nice way to do what I would like to do? Or have I manoeuvred myself into a corner here? Thanks very much in advance!</p>
  
  <p>Simon</p>
  
  <p>Some more information:</p>
  
  <p>In a ClassA I instantiate a ClassB which then inherits MyClass with the right type T.
  Then, in ClassA I also instantiate a ClassC which I give a reference to ClassB. Now, the error occurs, when I try to create <code>myIterator</code> in ClassC and try to do <code>myIterator-&gt;first</code>.</p>