No – but technically there is a work-around (not that i’d actually use it unless forced to):
for(struct { int a; char b; } s = { 0, 'a' } ; s.a < 5 ; ++s.a)
{
std::cout << s.a << " " << s.b << std::endl;
}
More Related Contents:
- Can I declare variables of different types in the initialization of a for loop? [duplicate]
- If statements in for loops
- How to print 5 values per line in C++ using only loop statement and no if-statements? [closed]
- Lowercase letters that did not appear in the array, in order [closed]
- Triple Nested For loop (C++) [closed]
- Don’t know how to add loop to my program…?
- Meaning of ‘const’ last in a function declaration of a class?
- What is an ‘undeclared identifier’ error and how do I fix it?
- Why use iterators instead of array indices?
- Defining static const integer members in class definition
- Removing item from vector, while in C++11 range ‘for’ loop?
- Same random numbers every loop iteration
- Static variables in C++
- Global scope vs global namespace
- Nested templates with dependent scope
- Does a C++11 range-based for loop condition get evaluated every cycle?
- Allow for Range-Based For with enum classes?
- Semicolon after class declaration braces
- Range based for-loop on array passed to non-main function
- Why are redundant scope qualifications supported by the compiler, and is it legal?
- Has the new C++11 member initialization feature at declaration made initialization lists obsolete?
- What does `auto && e` do in range-based for-loops?
- Redefinition allowed in C but not in C++?
- Creating N nested for-loops
- Why can’t redefine type names in class in C++?
- namespaces for enum types – best practices
- Is is a good practice to put the definition of C++ classes into the header file?
- What is the purpose of forward declaration?
- const reference to a temporary object becomes broken after function scope (life time)
- What is the meaning of ‘const’ at the end of a member function declaration?