Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   accessing inner struct members (http://www.velocityreviews.com/forums/t450775-accessing-inner-struct-members.html)

Walter Deodiaus 12-29-2005 07:00 PM

accessing inner struct members
 
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);




mlimber 12-29-2005 07:20 PM

Re: accessing inner struct members
 
Walter Deodiaus wrote:
> 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


Old Wolf 12-29-2005 10:19 PM

Re: accessing inner struct members
 
Walter Deodiaus wrote:

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



All times are GMT. The time now is 02:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.