This topic is now archived and is closed to further replies.

Parveen Kaler

Dynamic MultiDimensional array in class

Recommended Posts

Parveen Kaler    122
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?
class A
  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];

    for(int = 0; i < m_nx; i++)
      delete []m_vArray[i];

    delete []m_vArray;
  float  **m_vArray;
  int    m_nx;
Edited by - Parveen Kaler on July 30, 2001 1:21:18 PM Edited by - Parveen Kaler on July 30, 2001 2:04:31 PM

Share this post

Link to post
Share on other sites