Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What was `auto` used for before?

I know that before C++11 the auto keyword had a completely different meaning; it was a storage type specifier indicating an object that has automatic storage type (ie, placed on the stack).

That's how the theory goes... How would you actually use this keyword (syntax), and why? Also, I haven't seen this keyword in actual code pre-C++11; when was it useful (what time period)?

like image 863
Paul Manta Avatar asked Nov 25 '11 17:11

Paul Manta


1 Answers

It was used to declare a local variable with automatic storage duration (i.e., "on the stack").

At least since C90 it has been a useless keyword, since automatic storage duration is the default storage duration for a local variable.

like image 154
James McNellis Avatar answered Jan 26 '23 21:01

James McNellis