Each line contains 5 numbers.
I had to create a container for storing each line
<
class Data {
private:
double a[6];
public:
// default constructor
Data() {
for (int i = 0; i < 5; i++) {
a[i] = 0; }
}
// constructor
Data( double b[5]) {
for (int i = 0; i < 5; i++) {
a[i] = b[i];
}
}
};
>
So Each line is an object.
I will have to deal with more data like this so to segregate this I created another container:
<
// Container for holding lines
class Container {
private:
vector<Data> v1;
public:
// push object into a vector
void add(Data d) {
v1.push_back(d);
}
>
My job is to count an 3 days circular moving average for one before last column and add this information to Data container
So if we have: 75.779999
76.239998
78 --> Here I should start adding average: ~76.63
75.910004 --> ~76.71
74.989998 --> ~76.26
My problem is that I don't know how to access that one before last number from Container "point of view". For example I have Container x with 20 objects inside. Those Objects are my lines where that variable is hiding.
how to access that one before last number from Container "point of view".
The "one before last number" is inside the array double a[6] in class Data. If you wanted to get fancy, you could add a member function to Data to return the element a[3] - assuming there are five values contained in positions 0 to 4 inclusive.
From the Container point of view, each element of the array v1 has its own individual value, so there will be more than one "one before last number".
Just a thought, rather than writing customised classes, you might simply use a vector or two: