<p>I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance and I would be glad to accept your help.</p>

<p>I would like to expose an iterator for a class like this:</p>

<pre><code>template &lt;class T&gt;
class MyContainer
{
public:
    // Here is the problem:
    // typedef for MyIterator without exposing std::vector publicly?

    MyIterator Begin() { return mHiddenContainerImpl.begin(); }
    MyIterator End() { return mHiddenContainerImpl.end(); }

private:
    std::vector&lt;T&gt; mHiddenContainerImpl;
};
</code></pre>

<p>Am I trying at something that isn't a problem? Should I just typedef std::vector&lt; T >::iterator? I am hoping on just depending on the iterator, not the implementing container...</p>

This should do what you want:
```
```
typedef typename std::vector<T>::iterator MyIterator;
```
```
From
Accelerated C++
:
Whenever you have a type, such as
```
vector<T>
```
, that depends on a template parameter, and you want to use a member of that type, such as
```
size_type
```
, that is itself a type, you must precede the entire name by
```
typename
```
to let the implementation know to treat the name as a type.