How to define a dynamic 2D array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmag
    New Member
    • Feb 2014
    • 6

    How to define a dynamic 2D array

    my professor said one way for declaration dynamic 2d arrays.
    Code:
    int **a=new int *[m];
    int *x=new int[m*n];
    int *y=x;
    for(int j=0;j<m;j++)
    {
    a[j]=y;
    y+=n;
    }
    and i never understand this way.like what does y or x in this code.I want a person explain how works this code.if show with a image is better.thanks
    Last edited by Rabbit; Feb 3 '14, 08:24 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Read the Arrays Revealed article. Let us know if you still have questions after that.

    Comment

    Working...