• Advertisement


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

Dynamic MultiDimensional array in class

This topic is 6080 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
  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

  • Advertisement