Original Post
I wrote a class a while back that handles creating and using a 2D array. Works like a charm. Latley, I've needed to write the data of the actual array to a file, so I wrote a little function in the class, returnArray, to, well, return a the array. returnArray takes the adress of a temporay array, then copys the array to thes temporary array. Alas, all is not well in programming land. I get a lovely:
template<class T> void array2D<T>::returnArray(T &destArray)
{
for(int i = 0; i< (ARRAY_COLUMNS * ARRAY_ROW); i++)
destArray = Array;
}
seems simple enough. Array is of type T btw, aka, it's a templated class. So I then use it like thus:
//create the array to hold that map data.
array2D<int> tempMapData;
//3 X 3
tempMapData.createArray(3,3);
//map tiles
/*
0,1,2
2,1,0
1,1,1
*/
//set that up
tempMapData(0,0) = 0;
tempMapData(0,1) = 1;
tempMapData(0,2) = 2;
tempMapData(1,0) = 2;
tempMapData(1,1) = 1;
tempMapData(1,2) = 0;
tempMapData(2,0) = 1;
tempMapData(2,1) = 1;
tempMapData(2,2) = 1;
int *tempArray = new int [tempMapData.retnCol() * tempMapData.retnRow()];
tempMapData.returnArray(tempArray);
for(int i = 0; i<9;i++)
mapWriter.write<int>(tempArray);
e:\programing\directx\nocturne engine\source\nocturne\cmap.cpp(117) : error C2664: 'array2D<T>::returnArray' : cannot convert parameter 1 from 'int *' to 'int &'
with
[
T=int
]
soo...I've fiddled, and I'm sleepy, and I have no clue wtf i'm doing wrong. I feel kinda dumb, like I should know this, so please don't be too mean :P Thanks!