Error with reversing an array

I have a function that is supposed to reverse an array, but I get the same output back that went in. List going in is populated 1, 2,...18, 19, 20 and is supposed to return 20, 19, 18...2, 1. Instead I get another 1 - 20. Any help, tips or suggestions is greatly appreciated! Thanks in advance!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

    alist.reverse();
    cout << "Reverse New List alist : " << endl;
    cout << "  "  << alist << endl;

void List::reverse()
{
    // Create temporary holder
    List temp;

    // Populate temp list with current list
    for (int i = 0; i < Used; i++)
    {
        temp.MyAry[i]= MyAry[i];
    }

    // Repopulate current list
    for (int j = Used - 1; j > - 1; j--)
    {
        MyAry[j] = temp.MyAry[j];
    }
}
1
2
3
4
5
6
    // Repopulate current list
    const int lastIdx = Used-1 ;
    for (int i=0; i<Used; ++i)
    {
        MyAry[i] = temp.MyAry[lastIdx-i] ;
    }

Thanks so much! It works perfectly!
Topic archived. No new replies allowed.