By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Accessing the value of a struct

P: n/a
Hi

I have a COM component that passes some udts around.
The function header is thus:
void App::PassUdt(struct udtSR *pudtSR)
pudtSR has a member struct called udtValue1 of type udtLONG that has
the definition:
struct udtLONG
{
long lngValue;
enum enumVarStatus enmStatus;

};
what i want to do is set a LONG to the value stored in the lngValue
part of udtLONG.

however if I add
long lVal = pudtSR.udtValue1.lngValue;
I get the following error:
error C2228: left of '.udtValue1' must have class/struct/union type
Can anyone point me in the right direction ?
Many thanks
Steve

Sep 14 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 14 Sep 2006 04:26:12 -0700 in comp.lang.c++, "SteveB"
<st*********@callcredit.plc.ukwrote,
>long lVal = pudtSR.udtValue1.lngValue;

I get the following error:

error C2228: left of '.udtValue1' must have class/struct/union type
It's a pointer.

pudtSR->udtValue1.lngValue;
or
(*pudtSR).udtValue1.lngValue;
Sep 14 '06 #2

P: n/a

SteveB 写道:
Hi

I have a COM component that passes some udts around.
The function header is thus:
void App::PassUdt(struct udtSR *pudtSR)
pudtSR has a member struct called udtValue1 of type udtLONG that has
the definition:
struct udtLONG
{
long lngValue;
enum enumVarStatus enmStatus;

};
what i want to do is set a LONG to the value stored in the lngValue
part of udtLONG.

however if I add
long lVal = pudtSR.udtValue1.lngValue;
God, you just so careless to do so.
Pointers cannot use a dot operator.
>

I get the following error:
error C2228: left of '.udtValue1' must have class/struct/union type
Can anyone point me in the right direction ?
Many thanks
Steve
Sep 14 '06 #3

P: n/a

David Harmon wrote:
On 14 Sep 2006 04:26:12 -0700 in comp.lang.c++, "SteveB"
<st*********@callcredit.plc.ukwrote,
long lVal = pudtSR.udtValue1.lngValue;

I get the following error:

error C2228: left of '.udtValue1' must have class/struct/union type

It's a pointer.

pudtSR->udtValue1.lngValue;
or
(*pudtSR).udtValue1.lngValue;
thank you - that was perfect

Sep 14 '06 #4

P: n/a

jimmy wrote:
SteveB 写道:
Hi

I have a COM component that passes some udts around.
The function header is thus:
void App::PassUdt(struct udtSR *pudtSR)
pudtSR has a member struct called udtValue1 of type udtLONG that has
the definition:
struct udtLONG
{
long lngValue;
enum enumVarStatus enmStatus;

};
what i want to do is set a LONG to the value stored in the lngValue
part of udtLONG.

however if I add
long lVal = pudtSR.udtValue1.lngValue;
God, you just so careless to do so.
Pointers cannot use a dot operator.


I get the following error:
error C2228: left of '.udtValue1' must have class/struct/union type
Can anyone point me in the right direction ?


Many thanks


Steve
thanks for that jimmy.

Sep 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.