Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CScrollView to BitMap File Pin
Hamid_RT15-Sep-06 1:22
Hamid_RT15-Sep-06 1:22 
QuestionUsing .obj created in VC++ in MASM Pin
Piteco13-Sep-06 4:52
Piteco13-Sep-06 4:52 
QuestionCould anyone expain the "Static" to me Pin
bloodwinner13-Sep-06 4:27
bloodwinner13-Sep-06 4:27 
AnswerRe: Could anyone expain the "Static" to me Pin
led mike13-Sep-06 4:33
led mike13-Sep-06 4:33 
AnswerRe: Could anyone expain the "Static" to me Pin
toxcct13-Sep-06 4:35
toxcct13-Sep-06 4:35 
GeneralRe: Could anyone expain the "Static" to me Pin
bloodwinner13-Sep-06 5:01
bloodwinner13-Sep-06 5:01 
GeneralRe: Could anyone expain the "Static" to me Pin
toxcct13-Sep-06 5:12
toxcct13-Sep-06 5:12 
AnswerRe: Could anyone expain the "Static" to me Pin
Lilith.C13-Sep-06 17:45
Lilith.C13-Sep-06 17:45 
bloodwinner wrote:
again, I am still confusing...

is that
int i:
it will be ready when you start use it

static int i:
it will be ready long before you use it

So what's the use of the latter occasion? Since I don't use it, why should I care when it is created.


Imagine a function that animates something on the screen. Each call to the function updates the phase of the animation by using a counter to determine what's displayed. To this end you need an int as the counter and you declare it inside the function rather than having your primary program pass the counter to the function. If you declare the int as non-static but you increment the int each time you enter the function the value of the int goes away because the variable was created on the stack when the function began and it was removed when the function ended.

If you declare the int as static, whatever value it had on exit from the function is the value it will have when you call the function again because the variable was created before the program began execution and will not be destroyed until the program ends.

Lilith
GeneralRe: Could anyone expain the "Static" to me Pin
Akt_4_U13-Sep-06 17:49
Akt_4_U13-Sep-06 17:49 
AnswerRe: Could anyone expain the "Static" to me Pin
Hamid_RT14-Sep-06 8:53
Hamid_RT14-Sep-06 8:53 
QuestionInternal working of Try/Catch Pin
DavJes13-Sep-06 4:26
DavJes13-Sep-06 4:26 
AnswerRe: Internal working of Try/Catch Pin
led mike13-Sep-06 4:35
led mike13-Sep-06 4:35 
QuestionMySQL with MFC Pin
dcb123456713-Sep-06 4:18
dcb123456713-Sep-06 4:18 
AnswerRe: MySQL with MFC Pin
Chris Losinger13-Sep-06 5:08
professionalChris Losinger13-Sep-06 5:08 
QuestionCString Convert to LPCTSTR Pin
rxgmoral13-Sep-06 3:59
rxgmoral13-Sep-06 3:59 
QuestionRe: CString Convert to LPCTSTR Pin
prasad_som13-Sep-06 4:05
prasad_som13-Sep-06 4:05 
AnswerRe: CString Convert to LPCTSTR Pin
Zac Howland13-Sep-06 4:20
Zac Howland13-Sep-06 4:20 
AnswerRe: CString Convert to LPCTSTR Pin
toxcct13-Sep-06 4:21
toxcct13-Sep-06 4:21 
AnswerRe: CString Convert to LPCTSTR Pin
David Crow13-Sep-06 4:30
David Crow13-Sep-06 4:30 
AnswerRe: CString Convert to LPCTSTR Pin
Steve S13-Sep-06 6:34
Steve S13-Sep-06 6:34 
AnswerRe: CString Convert to LPCTSTR Pin
ThatsAlok13-Sep-06 18:51
ThatsAlok13-Sep-06 18:51 
AnswerRe: CString Convert to LPCTSTR Pin
Hamid_RT14-Sep-06 8:39
Hamid_RT14-Sep-06 8:39 
Question[Message Deleted] Pin
KKumarTG13-Sep-06 3:44
KKumarTG13-Sep-06 3:44 
AnswerRe: Exception in C++ Pin
Cedric Moonen13-Sep-06 3:46
Cedric Moonen13-Sep-06 3:46 
AnswerRe: Exception in C++ Pin
Zac Howland13-Sep-06 4:13
Zac Howland13-Sep-06 4:13 

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.