473,804 Members | 3,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::Uni on.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);

Dec 29 '05 #1
2 2230
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::Uni on.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

Dec 29 '05 #2
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.

Dec 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1352
by: S.Tobias | last post by:
Quote from 6.5.2.3 Structure and union members, Examle 3: The following is not a valid fragment (because the union type is not visible within function f): struct t1 { int m; }; struct t2 { int m; }; int f(struct t1 * p1, struct t2 * p2) { if (p1->m < 0) p2->m = -p2->m;
3
2359
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
8
3022
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
2
1774
by: Chad | last post by:
The following question stems from the following thread on comp.lang.c: http://groups.google.com/group/comp.lang.c/browse_thread/thread/0ad03c96df57381a/5f20260b30952fe7?hl=en#5f20260b30952fe7 I was sort of mystified by a comment made by Eric. And I quote: "You might also be confused by the fact that each `struct my_struct' contains a pointer to a `struct my_struct' object. There is nothing special about that inner pointer:
5
2350
by: joseph.paterson | last post by:
Hello, I'm having some trouble with accessing members of a structure i've defined... I've got something like this: #define bool short int #define TRUE 1 #define FALSE 0 #define SMOOTH_FACTOR (3.0 / 4.0)
14
3725
by: Kavya | last post by:
Here is the code int main(){ struct node{ int a; int b; int c; }; struct node s={3,5,6}; struct node *ptr=&s;
6
5035
by: earthwormgaz | last post by:
Is the following legal? class Outer { class Inner { private: Inner() { } };
9
4694
by: Matthias Buelow | last post by:
Hi folks, I've got something like: class Outer { int f(); friend class Inner; class Inner { int g() {
0
1267
by: MukeshChoudhari | last post by:
Hi, I have a struct in my application. public struct MyStruct { int a; public int b; } As C# says struct members are public by default, but I am not able to access this member in my main method using the object of Struct. MyStruct s=new MyStruct (); Console.WriteLine(s.a); // This statement gives compile time error
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.