Original Post
I used to remember how to do this the *correct* way. I left my copy of Effective C++ at home today. But is this the correct way to allocate a multidimensional array in a class?
Edited by - Parveen Kaler on July 30, 2001 1:21:18 PM
Edited by - Parveen Kaler on July 30, 2001 2:04:31 PM
class A
{
public:
A(unsigned int x,unsigned int y)
{
m_nx = x;
m_vArray = new float*[x];
for(int i = 0; i < y; i++)
m_vArray[i] = new float[y];
}
~A()
{
for(int = 0; i < m_nx; i++)
delete []m_vArray[i];
delete []m_vArray;
}
private:
float **m_vArray;
int m_nx;
}
|