Prop props array

i have one question, when we create the props array in the main function:

int main()
Prop props [2]{
Prop{LoadTexture (“nature_tileset/Rock.png”), Vector2{600.f,300.f}},
Prop{LoadTexture (“nature_tileset/Log.png”), Vector2{400.f,500.f}}

is the the object (istance of prop) build here or in the next range for loop cycle?

while (!WindowShouldClose())

for (auto pincopallo : props)
in practice is the object constructed from time to time in pincopallo variable?

It is constructed here and two Prop objects are instantiated.

pincopallo variable is used to iterate over the props array in this for-loop.

yes looking better, as explained int course, Prop{…} is the constructor
thanks you.

To be even more precise, a copy of the prop is assigned to pincopallo and that is used in the iteration of the for loop.

The fact that this is a copy isn’t that big of a deal, though. As we’re not interacting with the props directly and the code isn’t changing their properties.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms