Archived

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

Dynamic MultiDimensional array in class

This topic is 5982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
{
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;
}
      
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