Do you store store one off data arrays in a class?

This is a discussion on Do you store store one off data arrays in a class? within the C++ Programming forums, part of the General Programming Boards category; I have a class which when initialised performs a one off calculation using 3 data arrays. These arrays calculate the ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    13

    Question Do you store store one off data arrays in a class?

    I have a class which when initialised performs a one off calculation using 3 data arrays. These arrays calculate the coordinates of the class object (ita a rubixs cube btw).

    My question is this. Is it right to store these arrays within the class, or should they be outside it? Im not sure myself.

  2. #2
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    i think your asking if this array should be a class on its own or in another class? if that's what your asking it would depend on how complex each array element is. can you post code or give more details

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    It all depends on your style. OOP is just to help YOU organize your data - it's nothing for the computer but more work.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    13
    There are 2 arrays holding 153 elements between them, which create the 600 or so coordinates of the rubixs cube (27 smaller cubes, 8 vertices, 3 coordinate you do the math ).
    The arrays are only used when the rubixs cube is created.
    Is it neccessary to store the data in the class? Or is it good programming to encapsulate everything that the class can possibly use?

  5. #5
    Seeking motivation... endo's Avatar
    Join Date
    May 2002
    Posts
    537
    Assuming they don't ever change I would perhaps have them as a constant array declared at the top of the rubix class file, kind of like pretending to encapsulate the data. Alternatively, you might declare them to be a static member of the class - perhaps the better option. There are any number of possibilities but I would suggest using the one that suits your programming style.

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I wouldn't put them in a class, unless you plan on making your program use more than one rubix (SP?) cube, and the array values will change. Just my humble opinion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help on class coupling
    By andrea72 in forum C++ Programming
    Replies: 4
    Last Post: 04-17-2011, 10:16 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. binary tree token problem
    By OldSchool in forum C++ Programming
    Replies: 13
    Last Post: 05-28-2006, 10:42 PM
  4. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM

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