Is it bad practice to declare a typedef at class scope? Is it better to declare them for every function to make sure no one includes that file and then creates something with the same name?
For example
typedef std::vector<int>::size_type vec_int;
Would be useful in some of my headers as in some classes there are many functions that use this type, but on the other hand I would have to put it in the header, wouldn’t I? Or could I put it at the top of the source file?
I’d say just keep the scope to a minimum; with that, do whatever is cleanest.
If you use it for one function, keep it in that function’s scope. If you use it for several functions, make it a private typedef. And if you expect others to use it (out of utility, perhaps), make it public.
In code:
Hopefully that gives you an idea of what I mean.