Aina

Sydney, Australia

astrophysics student at University of Sydney

Sep
24
awarded Autobiographer
Sep
24
awarded Autobiographer
Sep
24
awarded Autobiographer
Sep
24
awarded Autobiographer
Sep
24
awarded Autobiographer
Sep
23
awarded Nice Question
Jul
2
awarded Curious
Jun
20
awarded Notable Question
Jan
15
awarded Notable Question
Nov
13
awarded Popular Question
Aug
29
awarded Popular Question
Apr
14
awarded Popular Question
Jan
7
awarded Teacher
Dec
17
accepted Accessing individual elements of C++ structure
Dec
17
comment Accessing individual elements of C++ structure
I still don't undestand how it is done because *it = myNewValue; only throws errors, I guess I'll have to start from scratch and find another, more transparent way to implement it but I will leave you in piece.
Dec
17
comment Accessing individual elements of C++ structure
thanks, which operator would I need to define if I wanted to overwrite the value inside the struc element? Say something like (inside of the loop) *it = myNewValue;
Dec
17
comment Accessing individual elements of C++ structure
thanks so much for your time, I didn't know you could put anything but one value inside the push_back(). Last question: how do I iterate through the struc? In my code above (edited again) I have added in the loop cout << arcStruc.xY.at(it); but it throws an error. I have also tried cout << arcStruc.xY[it]; but it also threw an error, what is the correct way to do this?
Dec
17
revised Accessing individual elements of C++ structure
edited the code
Dec
17
comment Accessing individual elements of C++ structure
do you mean something like that (see my edited solution?). As it stands now it fails on arcStruc.xY.push_back(pt.getX()); of course, but I don't understand from your answer how you can use arcStruc.xY.push_back().
Dec
17
revised Accessing individual elements of C++ structure
change the code
1 2 3 4 5