For the record, questions you didn't answer:
MikeyBoy wrote: |
---|
Why are you passing in i and j? |
(also, AbstractionAnon asked the same question)
AbstractionAnon wrote: |
---|
Why are i, j member variables? |
Is this supposed to be a constructor? |
SCB3 wrote: |
---|
As for AbstractionAnon's questions, I read those as statements to think about rather than questions to be answered. |
I can't speak for anyone but myself, but when I ask questions like that, it's not some kind of rhetorical device. It's because, by seeing your answer to the question, it helps us discover just what it is you're trying to achieve, and exactly what it is that you might have misunderstood.
I would need 4 cells in this case so 1 row/col is the start goal and the other row col is the end goal |
So, firstly, you need it to be a 2 x 2 array, not a 1 x 1 array.
If you do it that way, you need to be very clear on whether it's the "row" that represents the point, and the numbers within that row that represent the co-ordinates within that point, or vice versa. In other words, are the co-ordinates of the first point:
(dArray[0][0], dArray[0][1])
or are they:
(dArray[0][0], dArray[1][0])
This is an easy way to get confused and make mistakes. You might be better off defining a simple class or struct for a point:
1 2 3 4 5
|
struct Point
{
int x;
int y;
};
|
and then making
dArray a one-dimensional array of
Points. That would certainly make your code easier to understand, and would make it less likely that you'd make a mistake.