std::vector<std::array<sf::RectangleShape,number_of_blocks_per_shape>>::const_iterator iter;
for ( iter = forms.begin(); iter != forms.end(); iter++ )
{
//accessing the data in the vector
}
Ive been figuring this out, but i dont know how to access all elements in a 2D container through iterator.
Your 'iter' is an iterator to vector element. By dereferencing an iterator you access the pointed to object. In your case vector element is a std::array.
If you had vector of strings, how would you operate on them?
If you had single array object, how would you access its elements?
C++11 has auto and range-based loop too:
1 2 3 4 5
for ( constauto & arr : forms ) {
for ( constauto & shape : arr ) {
// shape is a reference to a RectangleShape object
}
}