classes vs. parametric arrays

This is a discussion on classes vs. parametric arrays within the C++ Programming forums, part of the General Programming Boards category; I've been recently informed that my data structures are all wrong. The system that I've been using is parallel arrays ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    classes vs. parametric arrays

    I've been recently informed that my data structures are all wrong. The system that I've been using is parallel arrays i.e. x and y of object 12 are x[12] and y[12], respectively. Apparently the "right" way to do this is with arrays of objects i.e. object[12].x and object[12].y. Is there a good reason for this (faster/less memory etc.) that I'm not aware of that makes objects the better option?
    Illusion and reality become impartiality and confidence.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    272
    I doubt there'll be much in it in respect of memory or speed. If you have functions that act on your arrays then you'll make it safer using a class/struct, as you'll only have to pass in one of the indices as an argument.
    Joe

  3. #3
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    well, it depends if you want to be an object oreinted programmer or not. Obviously both of the methods you mention work fine, but I would go with the object method because it fits better in the the object oriented paradigm and is therefor easier to understand and maintain.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic allocation of 2 dim. arrays in classes
    By circuitbreaker in forum C++ Programming
    Replies: 4
    Last Post: 02-10-2008, 11:13 AM
  2. Help with arrays and pointers please...
    By crazyeyesz28 in forum C++ Programming
    Replies: 8
    Last Post: 03-17-2005, 12:48 PM
  3. Questions on Classes
    By Weng in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2003, 05:49 AM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

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