I am trying to create a structure of double vectors in C++.
struct distance{
vector<double> x(10000);
vector<double> y(10000);
vector<double> z(10000);
};
distance distance_old, distance_new;
In the definition it throws an error saying:
error: expected identifier before numeric constant
error: expected ‘,’ or ‘...’ before numeric constant
Where am I going wrong?
I saw this post Structure of vectors C++
but it doesn’t seem to be working for me.
You are trying to construct the vectors in the structure, which can’t be done. You have to do it in a constructor just like a normal class: