I want to create a class with a long array of doubles, but various sections of the array can also be accessed by individual names. In other words
both access the same location. What is the most elegant way to get this done? Unions and #defines are both clumsy at best, as is relying on the storage order in the class being identical to the declaration order. Right now I have "part" be a function returning a pointer to (storage + 10), which requires an ugly extra set of parentheses.Code:
The application is scientific programming. I have routines that have a list of input variables and a list of output variables. Some routines need to know what the individual variables represent in order to compute values, while other routines just want the entire list of values in order to computer derivatives and such. There must be some way to do this elegantly in C++.
Thanks for any tips,