Dynamic structure error
Unsolved
General and Desktop
-
Hi to all.
First of all thank for helping me and reading this post.I am trying to create a dynamic structure.
My code is:Header:
typedef struct { //We define the line structure std::double_t x_start; std::double_t x_end; }struc_lines; private std::vector<struc_lines> lines_struct;
Now I would like to add x_start and x_end to the structure which we do not know the size (so because of that it is a dynamic structure).
I have tried with
lines_struct[i].y_start=(1.25); //For example
It compiles fine but it does not work.
How can I use .push_back for example in lines_struct.x_start???Thanks a lot.
-
Hi
You meanstruc_lines Line;
Line.x_start=100;
lines_struct.push_back(Line);Now it has 1 entry so
QDebug() << lines_struct[0].x_start;
should give 100.