Accessing the value of a struct

S

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;


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
 
D

David Harmon

On 14 Sep 2006 04:26:12 -0700 in comp.lang.c++, "SteveB"
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;
 
J

jimmy

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

SteveB

David said:
On 14 Sep 2006 04:26:12 -0700 in comp.lang.c++, "SteveB"


It's a pointer.

pudtSR->udtValue1.lngValue;
or
(*pudtSR).udtValue1.lngValue;

thank you - that was perfect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,187
Latest member
RosaDemko

Latest Threads

Top