473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

trouble accessing into a referenced variable

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)
. . .

Nov 13 '06 #1
4 1229
"Alan" <ja*********@verizon.netwrote:
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.
See below:
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)
. . .
--
To send me email, put "sheltie" in the subject.
Nov 13 '06 #2

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

Nov 13 '06 #3
Daniel,
Thanks! All the simpler examples of passing by reference
had examples like:

In function declaration: int& a

In function body: a* = 2

so I thought I needed it here. Duh! Alan

Nov 13 '06 #4

Alan wrote:
Daniel,
Thanks! All the simpler examples of passing by reference
had examples like:

In function declaration: int& a

In function body: a* = 2

so I thought I needed it here. Duh! Alan
no .. a*=2 is actualy a=a*2

Nov 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Fernando Rodríguez | last post by:
Hi, I haven't used Python in quite some time, and I'm bit puzzled by this: counter = 0 class Blah(object): def run(self): counter += 1
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
3
by: dave | last post by:
I am having trouble accessing a property set during run-time in a user control that I have built. The control is supposed to connect to a database using the path supplied by the developer at...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.