"Class that cannot be inherited ... C++" <> writes:
> Keith Thompson wrote:
>> writes:
>> > Dear All.
>> >
>> > As far as i know that Then memeory is divided into the three segements
>> >
>> > 1. Heap;
>> > 2. Stack;
>> > 3. Data segmnet;
>>
>> That may be true in some implementations, but none of these are C
>> terms. In some implementations, malloc() and friends allocate memory
>> from the "heap", local variables are on the "stack", and static and
>> global variables are in the "data segment" -- but others may do things
>> differently.
>>
> hi as u r writing that static and global will be in data segment , data
> segment is the part which is copied if an application is all ready in
> memory .
> eg. if internate exploreer is allready open and we have clicked it once
> more a new code copy will not be there only the data segment part will
> be cpoied in memory and same codesegment will be used .
> is it correct? it is .
Please don't use abbreviations like "u" and "r"; take the time to
spell out the words. Thank you.
> now
> i have program a application in which i have use a global static
> variable.
> if the data segment is holding the static and global variables so that
> segment should be copied to other segment (as a new instance of that
> process play) but what is happening that global static variable is
> incrementing for the all three instance of that process are running.
The behavior you're describing is system-specific. The C standard
doesn't even address the possibility of more than one program running
simultaneously.
If multiple copies of the same program are running simultaneously,
presumably they're not going to interfere with each other's variables
(if they did, they wouldn't be behaving in accordance with the
language standard). How this is done is up to the implementation.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.