Click here to Skip to main content
15,905,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDoes the static variable modifier make variable access faster? Pin
Dominik Reichl3-Jun-03 22:48
Dominik Reichl3-Jun-03 22:48 
AnswerRe: Does the static variable modifier make variable access faster? Pin
FlyingDancer3-Jun-03 23:19
FlyingDancer3-Jun-03 23:19 
GeneralRe: Does the static variable modifier make variable access faster? Pin
Dominik Reichl3-Jun-03 23:28
Dominik Reichl3-Jun-03 23:28 
AnswerRe: Does the static variable modifier make variable access faster? Pin
Andrew Walker4-Jun-03 1:03
Andrew Walker4-Jun-03 1:03 
GeneralRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 1:48
BhaskarBora4-Jun-03 1:48 
GeneralRe: Does the static variable modifier make variable access faster? Pin
Andrew Walker4-Jun-03 1:53
Andrew Walker4-Jun-03 1:53 
GeneralRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 21:12
BhaskarBora4-Jun-03 21:12 
AnswerRe: Does the static variable modifier make variable access faster? Pin
BhaskarBora4-Jun-03 1:42
BhaskarBora4-Jun-03 1:42 
hi there .. u r right partly...
all static variables (no matter where they are defined) are not created on stack like local vars. and also static vars are created once for a process/program and remain till the end. this is the reason when your function has static var array defined rather than a local var array, the execution is faster. as static var is created during the program startup and in your case not everytime when you invoke the function (recursive or otherwise). if it would have been a local array then execution would have been little slower as compare to the static array version (as OS will allocate the array on stack everytime you call the function and removes it from stack when function returns).

static var array is shared in all calls to the function. Also, there is a wastage of memory when you are not using the array. to over come this, you can define a 'int pointer' as static and allocate the memory when you need to use the array. when you no longer want the array, relase the allocated memory. this would be a smart solution !

"Think big, think fast, think ahead. Ideas are no one's monopoly"
GeneralRe: Does the static variable modifier make variable access faster? Pin
Dominik Reichl4-Jun-03 4:42
Dominik Reichl4-Jun-03 4:42 
Questionhow to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer3-Jun-03 22:25
FlyingDancer3-Jun-03 22:25 
AnswerRe: how to make Floppy-Disk-Device's LED blinking Pin
Toni784-Jun-03 19:51
Toni784-Jun-03 19:51 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer4-Jun-03 20:13
FlyingDancer4-Jun-03 20:13 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
Toni784-Jun-03 20:51
Toni784-Jun-03 20:51 
GeneralRe: how to make Floppy-Disk-Device's LED blinking Pin
FlyingDancer4-Sep-03 15:12
FlyingDancer4-Sep-03 15:12 
GeneralCFtpFileFind Bug ! Pin
oz_the_wizard3-Jun-03 21:52
oz_the_wizard3-Jun-03 21:52 
GeneralMaking selected item bk 50% transparent in a ownerdrawn clistctrl Pin
justin2233-Jun-03 21:42
justin2233-Jun-03 21:42 
GeneralRe: Making selected item bk 50% transparent in a ownerdrawn clistctrl Pin
Cris4-Jun-03 4:38
Cris4-Jun-03 4:38 
GeneralSpecial characters program Pin
meshteb3-Jun-03 21:35
meshteb3-Jun-03 21:35 
GeneralRe: Special characters program Pin
Ted Ferenc3-Jun-03 21:55
Ted Ferenc3-Jun-03 21:55 
GeneralRe: Special characters program Pin
Andrew Walker3-Jun-03 22:03
Andrew Walker3-Jun-03 22:03 
GeneralConverting _int64 to string Pin
Shah Shehpori3-Jun-03 21:04
sussShah Shehpori3-Jun-03 21:04 
GeneralRe: Converting _int64 to string Pin
askadar3-Jun-03 21:50
askadar3-Jun-03 21:50 
GeneralRe: Converting _int64 to string Pin
Mike Nordell4-Jun-03 3:31
Mike Nordell4-Jun-03 3:31 
GeneralMessage and Single Instance Pin
Rage3-Jun-03 20:49
professionalRage3-Jun-03 20:49 
GeneralChanging tooltips at runtime for a CWnd object Pin
Raghunandan S3-Jun-03 19:32
Raghunandan S3-Jun-03 19:32 

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.