I have a 2 dimensional structure of objects initialized as thus:
std::vector<std::shared_ptr<tile> > appearance;
for (int x = 0; x < building_data.x_width; x++)
{
appearance.push_back
(std::shared_ptr<tile>(new tile[building_data.y_length]));
}
now, as far as I can figure out, the only way to access a member function of a tile in this is to use
appearance.at(x).get()[y].member_function()
which is confusing and cumbersome, and I feel like I'm missing something.
Previously, I had used tile**
for the same structure, and the syntax of
tile[x][y]
was nice but the raw pointers were a headache.
So, is there a better way access functions of an object held in an array, where the first element in the array is pointed to by a smart pointer held in a vector? Wordy but its the best I have.