We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to create an array that can hold pairs of colour values for primary and secondary colours so the program can pick a pair of colours to use for display eg
pink & green, pink & blue, pink & yellow, green & pink, green & blue, blue & yellow etc
I've read up on 2d arrays but cannot figure out how to get this data into one - is this the right way to go about it, I'm a bit lost on this one....
Cheers Rich
Answers
Yes, 2D arrays would work.
Or just 2 arrays (1D)
not as elegant
OR go oop / objects
Yes, classes are a good fit.
See Common Questions: From several arrays to classes
My propose is to store the
color
pair as 1long
primitive datatype.Of course it's more complicated and needs helper functions in order to insert and extract
primary & secondary
color
from the storedlong
.But at least it's 1D array and more cache memory friendly: :P