Auto keyword with const variable

MGW mgw at yandex.ru
Wed Jul 24 02:46:18 PDT 2013


On Wednesday, 24 July 2013 at 08:07:55 UTC, Alex H wrote:
> This code:
>
> void test(const int n)
> {
> 	auto j = n;
> 	j++;
> }
>
> Gives this error:
> cannot modify const expression j
>
>
> Is this considered a feature or a bug? I would assume most 
> people
> wouldn't want new variables inheriting const.

There is no error. All right.

auto - the type expects the maximum transfer of properties from 
the context.
int j = n; j++ // if change j


More information about the Digitalmars-d-learn mailing list