C++ referencing an array of structs -
i'm new using c++ complicated programming. i've been sifting through leftover, uncommented, academic code handed down through department, , i've stumbled across have no real idea how google for. don't understand syntax in referencing array of structs.
here trimmed version of i'm struggling with:
typedef struct { double x0,y0; double r; } circle; double foo() { int n = 3; double mtt; circle circles[n]; (int = 0; < n; i++) { mtt += mtt_call_func((circles+i), n); } return mtt; } what (circles+i) mean in case?
edit: function should have (circles + i), not (circle + i).
circles+i equivalent &circles[i]. that's how pointer arithmetic works in c++.
why there pointer? well, when give name of array, in context other &circles or sizeof circles, temporary pointer created points first member of array; that's code works with. arrays second-class citizens in c++; don't behave objects.
(i'm assuming circle+i typo circles+i others suggested)
Comments
Post a Comment