In C++ grammar, different data types are separated with ;
(if not function). In for
loop, once the ;
is found the meaning is changed. i.e.
for (; ; )
Other reason is possibly to avoid complexity in an already complex grammar, this feature is not allowed.
If you want to declare variables in for
loop scope, then you can always simulate that situation:
int main()
{
{
double j = 3.0;
for (int i = 0; i < 10; i++, j+=0.1)
cout << i << j << endl;
}
return 0;
}