|
||
|
|
#1 (permalink) | |
|
Master of the Internet
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,226
|
Alright, so I have the following:
Code:
// Sort the Table.
void SortTable( int dims, int Table[][], int pos, int start, int end )
{
Quote:
How should I write this? |
|
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
|
You can't specify it like that if you need the second dimension to vary. Basically, C++ doesn't support multi-dimensional arrays. It supports arrays of arrays and not very well at that. Arrays are essentially just pointers, therefore it follows that arrays are just pointers to pointers. That is how you will need to pass it, as an int **.
Also, that error was referring to the fact that you don't actually specify the length of the rightmost dimensions of the array. What it wants you to do is specify the array like: int a[][10], with the rightmost dimensions explicit. Adding a third dimension gives something like: int a[][10][10]. If you don't know what the rightmost dimensions are, then you can't specify the parameter as an array. Last edited by Sep102; 04-05-2007 at 09:14 PM. |
|
|
|
|
|
#4 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,831
|
No, he gave you the answer:
Code:
void SortTable( int dims, int **Table, int pos, int start, int end ) The empty square bracket (int blah[]) notation is less widely used and means *almost* the exact same thing... its usually better to avoid it.
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
#6 (permalink) | |
|
RunUO Forum Moderator
|
Quote:
2 dimensional array is simply 1 dimensional array where each item in it isn't a normal item but another 1 dimensional array. The same can be said that any N dimensional array is simply 1 dimensional array where each item in it is an N-1 dimensional array (recursion should bump in just about now to fill the rest). If you really have to draw it I would draw 2 dimensional array (matrix) and mark each item with a letter (line) and number (row), then I would draw 2 dimensional arrays (matrices) and title them with the letter and number in the first matrix (I won't suggest doing it for more then 2x2x2x2). Just tell them to imagine that each matrix is a zoom-in presentation of 1 block in the original matrix. Personally I won't even try to have the students imagine a 4 dimensional array, it'll eat up all lesson time and leave them totally confused. P.S. Zippy can you please elaborate on the differences between the [] operator and the *operator in those cases?
__________________
I always try to help
![]() Sometimes, I don't know how.... ![]() My Web Page Forum Rules ------------------------------------------------------------- Extensive OWLTR System | Token System | World Teleporters ------------------------------------------------------------- Last edited by daat99; 04-06-2007 at 11:01 PM. |
|
|
|
|
|
|
#7 (permalink) |
|
Forum Expert
|
Doh' I feel like a dunce. I went away for about 5 minutes in the middle of typing that message and didn't proof read. I read your reply and was thinking "wtf is he explaining this?" Then i noticed my error.
"how to teach" Should have been "how hard it is to teach" Sorry 'bout that, daat. Very good explanation, though! |
|
|
|
|
|
#8 (permalink) | |
|
RunUO Forum Moderator
|
Quote:
![]()
__________________
I always try to help
![]() Sometimes, I don't know how.... ![]() My Web Page Forum Rules ------------------------------------------------------------- Extensive OWLTR System | Token System | World Teleporters ------------------------------------------------------------- |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|