C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2002, 10:40 AM   #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.
blood.angel is offline   Reply With Quote
Old 06-23-2002, 10:03 PM   #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
blight2c is offline   Reply With Quote
Old 06-23-2002, 11:17 PM   #3
Super Moderator
 
Join Date: Sep 2001
Posts: 4,746
It all depends on your style. OOP is just to help YOU organize your data - it's nothing for the computer but more work.
sean is offline   Reply With Quote
Old 06-24-2002, 04:32 AM   #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?
blood.angel is offline   Reply With Quote
Old 06-24-2002, 05:08 AM   #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.
endo is offline   Reply With Quote
Old 06-24-2002, 12:05 PM   #6
¡Amo fútbol!
 
Join Date: Dec 2001
Posts: 2,123
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.
golfinguy4 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting an error with OpenGL: collect2: ld returned 1 exit status Lorgon Jortle C++ Programming 6 05-08-2009 08:18 PM
help on class coupling andrea72 C++ Programming 3 07-05-2006 12:15 PM
binary tree token problem OldSchool C++ Programming 13 05-28-2006 10:42 PM
[question]Analyzing data in a two-dimensional array[with code] burbose C Programming 4 06-14-2005 05:45 AM
structure vs class sana C++ Programming 13 12-02-2002 07:18 AM


All times are GMT -6. The time now is 04:58 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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