accessing inner struct members

W

Walter Deodiaus

I have
typedef struct {
union _union{
....
struct {
int i;
}u1;
....
}Union;
} Struct ;


now I want to define a method's signaure whose first arg will be "u1"

e.g. foo(Struct::Union.u1)

Is this possible without changing the layout to
struct _u1{
int b;
} ;
typedef struct {
union _union{
....
_u1 u1;
....
}Union;
} Struct ;

method's signature
foo(u1 the_u1);
 
M

mlimber

Walter said:
I have
typedef struct {
union _union{
...
struct {
int i;
}u1;
...
}Union;
} Struct ;


now I want to define a method's signaure whose first arg will be "u1"

e.g. foo(Struct::Union.u1)

Is this possible without changing the layout to
struct _u1{
int b;
} ;
typedef struct {
union _union{
...
_u1 u1;
...
}Union;
} Struct ;

method's signature
foo(u1 the_u1);

You want something like:

struct S1
{
union U
{
char c[4];
struct S2
{
int i;
} s2;
} u;
};

void foo(S1::U::S2);

int main()
{
foo( S1::U::S2() );
}

Cheers! --M
 
O

Old Wolf

Walter said:
struct {
int i;
}u1;

now I want to define a method's signaure whose first arg will be "u1"

You didn't give the struct a type name, so it is impossible to
refer to its type.
 

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

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top