Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > accessing inner struct members

Reply
Thread Tools

accessing inner struct members

 
 
Walter Deodiaus
Guest
Posts: n/a
 
      12-29-2005
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);



 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      12-29-2005
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

 
Reply With Quote
 
 
 
 
Old Wolf
Guest
Posts: n/a
 
      12-29-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
Generically accessing members of a struct. david.chanters@googlemail.com C Programming 3 05-24-2009 06:59 PM
Accessing members of a struct joseph.paterson@gmail.com C Programming 5 04-13-2006 02:49 AM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM
Accessing C struct members via T_PTROBJ Mark Shelor Perl Misc 2 10-25-2003 10:05 AM



Advertisments