Has anyone ever seen the storage class auto explicitly in use in c/c++? If so, in what situation?
auto is never useful in current C/C++ because all variables are implicitly auto. It is useful in C++0x, where it can replace the type declaration entirely - if you have a variable with an initial assignment, 'auto' will just make it the type of that assignment value, as in the comments.
No, it's assumed if you omit the class specifier. The only reasonable uses I can think of would be to call attention to a particular local variable that overrides, say, a global variable with the same name, or as an interview question.
Chances are, you'll confuse the poor programmer who's stuck maintaining the code!
I haven't seen auto
used in code written in the last 10+ years. There is no reason to use auto
since the only places you can use it is where it is implied anyway. The only reason it still exists is for backwards compatibility but it should be avoided in new code.
As Alex has covered, auto is used in C++0x to declare types in initialisation declarations where the type is inferred from the initialisation code.
There was a proposal for it to also be used as a return type, where the type is deduced from code returning a value. However this gave rise to an ambiguity so, at time of writing, something more consistent with C++0x's lambda syntax is being considered.
In GCC you might need auto to declare nested function in order to be able to define it anywhere in function body - see http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Nested-Functions.html