2D Arrays: Column/Row Order

This is a discussion on 2D Arrays: Column/Row Order within the C++ Programming forums, part of the General Programming Boards category; I've noticed something odd in most of the books/tutorials I've read that deal with 2D arrays, including the current book ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    37

    Exclamation 2D Arrays: Column/Row Order

    I've noticed something odd in most of the books/tutorials I've read that deal with 2D arrays, including the current book I'm reading, Tom Swan's C++ Primer (1992).

    From what I've read, in C++, the standard way to order the indicies is row#, column#.

    The problem I have with that is that I think of coordinates in terms of (X, Y). Picking the ROW number first is effectively the same as picking the Y-coordinate; picking the column number is the same as picking the X-coordinate. This means that the coordinates are (Y, X), not (X, Y).

    I find this confusing, and so I use (X, Y). The question is: Does this matter? If I order my array (x, y) instead of (y, x), will others be confused by my code? Which way should I use?

    --Ashiq

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Use whatever you like, as long as you use it that way consistently. There is no standard way of doing it (some libraries will do it one way, some the other, though this is usually a hidden implementation detail). If you think it might be confusing to someone (which I doubt), just put a comment in.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Large 2D Array's Problem
    By kas2002 in forum C Programming
    Replies: 4
    Last Post: 05-25-2009, 01:42 PM
  2. Help with 2d arrays
    By thamiz in forum C Programming
    Replies: 25
    Last Post: 05-25-2008, 06:06 AM
  3. 2D Array's, assigning chars.
    By gman89 in forum C Programming
    Replies: 9
    Last Post: 04-27-2008, 12:03 AM
  4. 2D arrays programming, please help
    By mfskratch in forum C Programming
    Replies: 4
    Last Post: 11-01-2007, 01:41 PM
  5. 2D Dynamically allocated pointer arrays
    By Lionmane in forum C Programming
    Replies: 37
    Last Post: 06-11-2005, 11:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21