Question: 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.

I would like to expose an iterator for a class like this:

```
template <class T>
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<T> mHiddenContainerImpl;
};

```

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

Answer: 
You may find the following article interesting as it addresses exactly the problem you have posted: [On the Tension Between Object-Oriented and Generic Programming in C++ and What Type Erasure Can Do About It](http://www.artima.com/cppsource/type_erasure.html)
This should do what you want:

```
typedef typename std::vector<T>::iterator MyIterator;

```

From [Accelerated C++](http://www.acceleratedcpp.com/):

> 
> 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.
> 
> 
>