Click here to Skip to main content
15,902,715 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: scope in functions Pin
kakan25-Oct-06 4:01
professionalkakan25-Oct-06 4:01 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 4:07
minkowski25-Oct-06 4:07 
GeneralRe: scope in functions Pin
kakan25-Oct-06 4:10
professionalkakan25-Oct-06 4:10 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 4:21
minkowski25-Oct-06 4:21 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 4:29
minkowski25-Oct-06 4:29 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 4:40
minkowski25-Oct-06 4:40 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 4:49
minkowski25-Oct-06 4:49 
GeneralRe: scope in functions Pin
kakan25-Oct-06 19:53
professionalkakan25-Oct-06 19:53 
Sorry for the delay. It's due to the fact I went home from work yesterday. Smile | :)
That's right, a static variable just gets initialized once.
Besides, there are just one copy of it, in the heap.

The fact that it is stored in the heap (as opposite to the stack), makes it protected from alterations.

So if you want to make sure (as in this case) that a value, returned from a function will contain the same value, static is the way to go.

This goes for plain C. For C++, a class member variable does the same.

Kakan

Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

GeneralRe: scope in functions Pin
minkowski25-Oct-06 23:02
minkowski25-Oct-06 23:02 
GeneralRe: scope in functions Pin
kakan25-Oct-06 23:47
professionalkakan25-Oct-06 23:47 
GeneralRe: scope in functions Pin
minkowski25-Oct-06 23:14
minkowski25-Oct-06 23:14 
GeneralRe: scope in functions Pin
Nemanja Trifunovic25-Oct-06 2:29
Nemanja Trifunovic25-Oct-06 2:29 
AnswerRe: scope in functions Pin
cmk25-Oct-06 7:31
cmk25-Oct-06 7:31 
Questiono Pin
zizzzz25-Oct-06 0:27
zizzzz25-Oct-06 0:27 
AnswerRe: o Pin
_AnsHUMAN_ 25-Oct-06 0:35
_AnsHUMAN_ 25-Oct-06 0:35 
AnswerRe: o Pin
toxcct25-Oct-06 0:39
toxcct25-Oct-06 0:39 
GeneralRe: o Pin
zizzzz25-Oct-06 0:55
zizzzz25-Oct-06 0:55 
GeneralRe: o Pin
Oliver12325-Oct-06 10:17
Oliver12325-Oct-06 10:17 
GeneralRe: o Pin
toxcct25-Oct-06 21:37
toxcct25-Oct-06 21:37 
GeneralRe: o Pin
Iain Clarke, Warrior Programmer25-Oct-06 3:22
Iain Clarke, Warrior Programmer25-Oct-06 3:22 
GeneralRe: o Pin
zizzzz25-Oct-06 3:31
zizzzz25-Oct-06 3:31 
GeneralRe: o Pin
toxcct25-Oct-06 3:36
toxcct25-Oct-06 3:36 
Questionconverting activex dll into a executable application Pin
BK Pradeep25-Oct-06 0:21
BK Pradeep25-Oct-06 0:21 
AnswerRe: converting activex dll into a executable application Pin
Cedric Moonen25-Oct-06 1:15
Cedric Moonen25-Oct-06 1:15 
Questionchanging of views Pin
radhika2825-Oct-06 0:20
radhika2825-Oct-06 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.