Can I declare variables of different types in the initialization of a for loop? [duplicate]
Yes, that is prohibited. Just as otherwise you cannot declare variables of differing types in one declaration statement (edit: modulo the declarator modifiers that @MrLister mentions). You can declare structs for (struct { int a = 0; short b = 0; } d; d.a < 10; ++d.a, ++d.b ) {} C++03 code: for (struct { … Read more