I have a struct that is filled with vectors.
struct structtype{
vector<double> vec1;
vector<double> vec2;
vector<int> vec3;
};
I want to be able to take the specific elements from one struct and add them to another. Sort of like
structtype myStructA
myStructA.add(myStructB.at(i))
so I'm building myStructA
out of specific elements of myStructB
. I'm wondering if within the definition of structtype
I can just include something like..
struct structtype{
vector<double> vec1;
vector<double> vec2;
vector<int> vec3;
void Add(structtype myStructtoAdd, int i){
vec1.push_back(myStructtoAdd.vec1.at(i));
vec2.push_back(myStructtoAdd.vec2.at(i));
vec3.push_back(myStructtoAdd.vec3.at(i));
};
};
Will this work? And regardless is there a better way to do this?