'auto' keyword

DLearner bmqazwsx123 at gmail.com
Sun Mar 12 13:07:58 UTC 2023


Is it correct that this _single_ keyword is used to indicate 
_two_ quite different things:

1. As a shorthand to make the type of the variable being declared 
the same as the type on the right hand side of an initial 
assignment.

Example: ```auto A = 5;``` makes A an int.

2. To indicate storage class of variable.

Example: ```auto int A;``` (I guess) makes A have automatic 
storage, ie contents lost when control goes out of scope, unlike 
static.

Best regards


More information about the Digitalmars-d-learn mailing list