Alan wrote:
> I`m having trouble figuring out the correct syntax for accessing an
> element of a struct variable (t_list) passed by reference to a
> function. The compiler does not like the code below when I added the
> "&" in the call and the "*" in the body of the function. It provides
> the error: "expected primary-expression before '.' token"
>
> How do you properly use a variable passed by reference to access
> into its structure?
>
> Thanks in advance, Alan
>
> struct report
> {
> int time;
> double xcor; double ycor; double speed;
> };
>
> void add_report (report t, vector<report>& t_list)
> {
> bool found = false;
> for (int i = 0; i < t_list*.size(); i++)
> if (t.time == t_list[i]*.time)
This works for me
struct report
{
int time;
double xcor; double ycor; double speed;
};
void add_report (report t, vector<report>& t_list)
{
bool found = false;
int i =0;
for (int i = 0; i < t_list.size(); i++)
if (t.time == t_list[i].time) i = 0;
}
I am not sure if I misunderstand but I do not know why you are using *
N
|