template < typename T > T ** New2DArray(int cols, int rows)
{
T **ret = new T *[rows];
for (int i = 0; i < rows; i++)
{
ret[i] = new T[cols];
}
return ret;
}
//some function...
c=New2DArray<char>(40,15);
c[2][5]=0;//<- this is where it says it has Access violation writing location 0xabababab(yes it's 0xabababab-not anything else)
//the rest
same as the example from first post, but without function, but doing that for lets say 10 variables is kinda lot of coding so I thought of creating a function for that...
the part w/o function works, but the one with it doesn't, however they do the same thing...
The code where the assignment happens looks a little contrived. I suspect there is some code between the allocation and assignment that is causing the problem.