Answer the question
In order to leave comments, you need to log in
How to organize a for in loop in c++? Is it possible at all?
Spoiled JS, I returned to the pros, which I didn’t really know. I really want to bypass the properties of an object in a loop. So far, this seems to me only in the form of creating an array of properties.
Answer the question
In order to leave comments, you need to log in
C ++11 introduced this feature:
int a[] = { 1, 2, 3 };
for (int &i : a)
{
std::cout << "Test new for :" << i << std::endl;
}
Nanny, I ate with them . What does bypass mean?
Let's go around all your human qualities in a cycle.
Perhaps you should use std::map to store the properties of an object if they are of the same type (double in this example). If you are talking about iterating over all the fields of the class, then this cannot be done, because they can be of different types and it is not clear what to do with them.
And why do you need it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question