Click here to Skip to main content
15,909,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: multiple document-view architecture Pin
David Crow24-Aug-07 6:03
David Crow24-Aug-07 6:03 
AnswerRe: multiple document-view architecture Pin
devvvy23-Aug-07 22:50
devvvy23-Aug-07 22:50 
GeneralRe: multiple document-view architecture Pin
Jim Crafton24-Aug-07 7:19
Jim Crafton24-Aug-07 7:19 
Questionstatic variable Pin
George_George23-Aug-07 19:22
George_George23-Aug-07 19:22 
AnswerRe: static variable Pin
User 58385223-Aug-07 19:27
User 58385223-Aug-07 19:27 
GeneralRe: static variable Pin
George_George23-Aug-07 19:35
George_George23-Aug-07 19:35 
GeneralRe: static variable Pin
User 58385223-Aug-07 19:42
User 58385223-Aug-07 19:42 
GeneralRe: static variable Pin
George_George23-Aug-07 20:01
George_George23-Aug-07 20:01 
Thanks Josh,


Good answer! I have a further question about programming best practice. Do you think it is safe to let the address of the *local* static variable as the return value of a function? Then other part of code (out of this function) will access or even modify the variable by the returned address of the *local* static variable?

Any disadvantages of this approach?

Example,

<br />
<br />
int* func()<br />
{<br />
    static int i;<br />
    // other code<br />
<br />
    return &i;<br />
}<br />
<br />



regards,
George
GeneralRe: static variable Pin
ThatsAlok23-Aug-07 20:04
ThatsAlok23-Aug-07 20:04 
GeneralRe: static variable Pin
George_George23-Aug-07 20:29
George_George23-Aug-07 20:29 
GeneralRe: static variable Pin
User 58385223-Aug-07 20:06
User 58385223-Aug-07 20:06 
GeneralRe: static variable Pin
ThatsAlok23-Aug-07 20:10
ThatsAlok23-Aug-07 20:10 
GeneralRe: static variable Pin
User 58385223-Aug-07 20:15
User 58385223-Aug-07 20:15 
GeneralRe: static variable Pin
George_George23-Aug-07 20:22
George_George23-Aug-07 20:22 
GeneralRe: static variable Pin
George_George23-Aug-07 20:27
George_George23-Aug-07 20:27 
GeneralRe: static variable Pin
ThatsAlok23-Aug-07 20:37
ThatsAlok23-Aug-07 20:37 
GeneralRe: static variable Pin
George_George23-Aug-07 20:55
George_George23-Aug-07 20:55 
GeneralRe: static variable Pin
ThatsAlok24-Aug-07 7:51
ThatsAlok24-Aug-07 7:51 
GeneralRe: static variable Pin
George_George23-Aug-07 20:19
George_George23-Aug-07 20:19 
GeneralRe: static variable Pin
User 58385223-Aug-07 20:29
User 58385223-Aug-07 20:29 
GeneralRe: static variable Pin
George_George23-Aug-07 20:31
George_George23-Aug-07 20:31 
GeneralRe: static variable Pin
User 58385223-Aug-07 20:36
User 58385223-Aug-07 20:36 
GeneralRe: static variable Pin
George_George23-Aug-07 20:51
George_George23-Aug-07 20:51 
GeneralRe: static variable Pin
User 58385223-Aug-07 20:55
User 58385223-Aug-07 20:55 
GeneralRe: static variable Pin
George_George23-Aug-07 22:27
George_George23-Aug-07 22:27 

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.