2D array pointer as function argument
in main:
double heightField[MAP_SIZE][MAP_SIZE];
Terrain *terrain = new Terrain();
terrain->generateTerrain( &heightField );
in Terrain:
//function sig
void Terrain::generateTerrain1( double *pHeightMap[][MAP_SIZE] )
Display.cpp: In member function `int Display::update_display()':
Display.cpp:1112: error: no matching function for call to `Terrain::generateTerrain1(double (*)[512][512])'
Terrain.cpp:58: note: candidates are: void Terrain::generateTerrain1(double* (*)[512])
make: *** [Display] Error 1
Why doesn't it like it ?
I think you want void generateTerrain( double pHeightMap[][MAP_SIZE] ) and terrain->generateTerrain( heightField );
Also, isn't it possible to just have a (double* pHeightTerrain) istead of having the brackets in their?
Alternatively you could use std::vector
There's also an interesting thread about 2D arrays in C++ here There's also some discussion about boost::multi_array in that thread as well
std::vector< std::vector< double > > heightField;// or like this (I personally find it more readable, but that might just be me)std::vector<std::vector<double> > heightField;
There's also an interesting thread about 2D arrays in C++ here There's also some discussion about boost::multi_array in that thread as well
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement