Thread: classes vs. parametric arrays

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

    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
    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.

  3. #3
    Join Date
    Nov 2002
    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, 12:13 PM
  2. Help with arrays and pointers please...
    By crazyeyesz28 in forum C++ Programming
    Replies: 8
    Last Post: 03-17-2005, 01:48 PM
  3. Questions on Classes
    By Weng in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2003, 06: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