const dynamic array

Hi mates ;)

I am making a game and for the map I have a dynamic array:
 
Tile ** Ground;

I want the ground/map to be const so you simply just cant change the pointers direction.
I tried this one: Tile const*const* Ground;
But I cant define it afterwards!
The code for making the map is this:
1
2
3
4
Tile ** Ground;
Ground = new Tile const*[m_X];
    for(unsigned int x = 0 ; x < m_X ; x++)
        Ground[x] = new const Tile[m_Y];



Any ideas how to solve this?
Last edited on
You could move the initialization code to a separate function that return Tile ** and do Tile const*const* Ground = function();.
Note that 'Tile const*const*' makes the Ground pointer variable. You probably want either 'Tile const*const*const' or 'Tile *const*const'.
Thank you very much, that worked ;)
Topic archived. No new replies allowed.