473,659 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

static structure

3 New Member
i am confused about static structure...

static struct
{
int a;

}st;

what is the difference between static structure and normal structure?
Jun 1 '07 #1
7 54804
Savage
1,764 Recognized Expert Top Contributor
i am confused about static structure...

static struct
{
int a;

}st;

what is the difference between static structure and normal structure?
If static keyword is applied to struct(or class),all of the members are static.

Savage
Jun 1 '07 #2
svlsr2000
181 Recognized Expert New Member
If static keyword is applied to struct(or class),all of the members are static.

Savage
hi savage,
is this c++ or java. I dont think there is something like static class in c++
please see this. I have not come across this in my compiler document.
:(
http://www.thescripts.com/forum/thread647427.html
Jun 1 '07 #3
padmahasini
3 New Member
i have to know about static struct in c-language..
Jun 1 '07 #4
padmahasini
3 New Member
when we declare static to a structure all the element will not become static...
because when varibales of structure are being re-intialized again...where as in static varibale will not reintialize .....

Then what is the use of declaring a structure as static?
Jun 1 '07 #5
Banfa
9,065 Recognized Expert Moderator Expert
If static keyword is applied to struct(or class),all of the members are static.
This isn't right.

It is not the structure that is declared static but the variable st. A variable declaration has the basic structure

[Storage Specifiers] [Type] [Variable Name];

This this case

Storage Specifiers
static

Type
struct
{
int a;

}

Variable Name
st

What the static keyword means is somewhat dependent on where this declaration appears in the rest of the code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent while the function is not running. Outside a function it merely indicates that the variable is not accessable outside the file it is in.

So the static in your declaration means exactly the same as the static in this declaration

Expand|Select|Wrap|Line Numbers
  1. static int integer_variable;
  2.  
Jun 1 '07 #6
AdrianH
1,251 Recognized Expert Top Contributor
This isn't right.

It is not the structure that is declared static but the variable st. A variable declaration has the basic structure

[Storage Specifiers] [Type] [Variable Name];

This this case

Storage Specifiers
static

Type
struct
{
int a;

}

Variable Name
st

What the static keyword means is somewhat dependent on where this declaration appears in the rest of the code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent while the function is not running. Outside a function it merely indicates that the variable is not accessable outside the file it is in.

So the static in your declaration means exactly the same as the static in this declaration

Expand|Select|Wrap|Line Numbers
  1. static int integer_variable;
  2.  
Thank you Ben, when I was reading all of the responses, I was about to scream. ;)

And just to clarify, the struct specified is what is called an anonymous struct. It is has no name.


Adrian
Jun 1 '07 #7
zidane
1 New Member
it's sure that we can write static struct on c program
that's a way to prohibit the user to access on the structure
from outside ,
it's generally used on stack defenition
Dec 20 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4540
by: Tino | last post by:
From Stroustrup( TC++PL, Appendix C.13 ) I thought that this was the way (and the only way perhaps) to have a common static member for all classes generated from a template. Though compiling this with MSVC++ 6, it compiles but errors on linking: unresolved external symbol "protected: static class structure * store_base::m_pST I know that MSVC++ 6.0 has shoddy support of template features...does this case fall in that class. I'd...
7
11996
by: Raxit | last post by:
Can A C Program having static Variable in Structure is possible..... i.e. struct A { int a; static int b; };
0
941
by: Shrage H. Smilowitz | last post by:
I have posted this question in the vision forum and got no response, so maybe one of the vb developers here can aswere me. In VB.net classes can have Properties (Attributes in UML), Functions (Operations in UML) How do i show a Class Event in a UML Static structure. Also, it seems like interfaces in a static structure does not support Operations waht do i do if want to represent a VB.net interface that has properties and events.
4
2558
by: sandeep | last post by:
Hi why we cannot have static as a structure member? & also is there any way to achive data hiding in C at this level( i.e. access only selected structure member ) following code gives syntax error struct xxxx { static int i; // int j; };
6
5893
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example will prove useful. structure MyStruct { // this is a complicated struct declaration in the sense
5
8643
by: kselvaakumar | last post by:
I have declared a global structure like this: struct { float a; float b; }static one; This is in a separate header file file1.h; Now how can i initialise those variables one.a and one.b in another cpp file.
5
11114
by: Bob Altman | last post by:
Hi all, I have a private static structure in a C++ class (it's a CRITICAL_SECTION structure) that needs to be initialized by passing its address to a routine (InitializeCriticalSection). Since C++ apparently doesn't allow a static constructor routine, how do I initialize my static member variable prior to allowing any instances to be constructed? TIA - Bob
27
5500
by: arkmancn | last post by:
Any comments? thanks. Jim
6
1931
by: jeddiki | last post by:
I am struggling with how I should store this data. I get an xlm update every day which contains about 20,000 rows of data. There are some new rows, maybe 150 a week, and some of the existing rows data changes. Approximately 97 % of all the data is the same each day with just 3% changing. I am using Mysql database tables. So I was thinking that the best way to store the data would be:
0
8341
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
8539
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
8630
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...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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
5650
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
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
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.