Do not do this in (1).
Everyone has been cursing your name for a thousand years. As a user of your class, I am not against you polluting your own namespace. But I will be upset if you pollute any of my namespaces (including the global one), as this will affect how my code is compiled. Why is "using namespace std" considered bad practice?
You cannot use it in (4) or (5).
Since I (personally) would like to tie it as close to the point of use as possible (to prevent pollution).
The best you can do is (3).
But I wouldn’t even do that. I am clearly about something from the standard. But I would type the container type.
private:
This is the best method since you only need to make changes in one place and the changes will be cascaded.
// Sub typedefs now will no longer need to change if you change // The type of container. Just change the container typedef and // now the iterators are automatically correct. public: //(so at 4) Iterators are public (and not exposing the implementation). typedef MyCont::iterator iterator; typedef MyCont::const_iterator const_iterator;
source share