Why not non-const reference to temporary objects? [duplicate]

The original case for not allowing references to temporaries was for function parameters. Suppose this was allowed:

void inc(double& x)
{ x += 0.1; }

int i = 0;
inc(i);

Why isn’t i changed?

Leave a Comment