Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Zip/Archive Pin
Hamid_RT17-Jun-07 22:32
Hamid_RT17-Jun-07 22:32 
Questiondialog box derived from CWnd class Pin
prithaa17-Jun-07 21:40
prithaa17-Jun-07 21:40 
AnswerRe: dialog box derived from CWnd class Pin
Nelek17-Jun-07 21:57
protectorNelek17-Jun-07 21:57 
GeneralRe: dialog box derived from CWnd class Pin
prithaa17-Jun-07 22:43
prithaa17-Jun-07 22:43 
GeneralRe: dialog box derived from CWnd class Pin
Nelek17-Jun-07 23:25
protectorNelek17-Jun-07 23:25 
GeneralRe: dialog box derived from CWnd class Pin
prithaa18-Jun-07 0:16
prithaa18-Jun-07 0:16 
GeneralRe: dialog box derived from CWnd class Pin
Nelek18-Jun-07 4:13
protectorNelek18-Jun-07 4:13 
QuestionLinkage of local static variables in inline member function Pin
Stephen Boissiere17-Jun-07 21:35
Stephen Boissiere17-Jun-07 21:35 
Hi, I recently posted an article (http://www.codeproject.com/useritems/VC2003MeyersSingletonBug.asp) and one of the comments raised a question that I cannot find a definitive answer for. I'm hoping somebody can help here. The question is:

In C++, if an inline class member function that contains a local static variable is included in a header which is included in more than one CPP file, does the linker garuantee that the static variable is treated as a single instance?

So in foo.h:

class foo
{
public:
    int bar()
    {
        static int i = 0;
        ++i;
        return i;
    }
};


And in fooA.cpp:

#include "foo.h"
extern void fooB();
int main()
{
    foo f;
    printf ( "%i", f.bar());
    fooB();
    return 0;
};


And in fooB.cpp:

#include "foo.h"
void fooB()
{
    foo f;
    printf ( "%i", f.bar());
};


Should I get the output:

12


Or:

11


BTW, I know what actually happens in my similar real code - I get "12" which is what I expect. But I'd like to know if this is C++ standard behaviour, undefined in the standard or just an MS compiler quirk. Thanks for reading.
AnswerRe: Linkage of local static variables in inline member function Pin
Matthew Faithfull18-Jun-07 3:37
Matthew Faithfull18-Jun-07 3:37 
GeneralRe: Linkage of local static variables in inline member function Pin
Stephen Boissiere18-Jun-07 4:06
Stephen Boissiere18-Jun-07 4:06 
QuestionRegarding connection point notifications. Pin
Raj Prathap17-Jun-07 21:07
Raj Prathap17-Jun-07 21:07 
AnswerRe: Regarding connection point notifications. Pin
Matthew Faithfull18-Jun-07 1:59
Matthew Faithfull18-Jun-07 1:59 
Questionmsi file Pin
deeps_cute17-Jun-07 20:39
deeps_cute17-Jun-07 20:39 
AnswerRe: msi file Pin
Hamid_RT17-Jun-07 20:50
Hamid_RT17-Jun-07 20:50 
GeneralRe: msi file Pin
deeps_cute17-Jun-07 21:24
deeps_cute17-Jun-07 21:24 
GeneralRe: msi file Pin
Hamid_RT17-Jun-07 22:26
Hamid_RT17-Jun-07 22:26 
QuestionSliderbar Problem Pin
scody17-Jun-07 20:36
scody17-Jun-07 20:36 
AnswerRe: Sliderbar Problem Pin
Randor 18-Jun-07 4:23
professional Randor 18-Jun-07 4:23 
QuestionHow to make Intelligent connectors using VC++ Pin
whatitis17-Jun-07 19:09
whatitis17-Jun-07 19:09 
AnswerRe: How to make Intelligent connectors using VC++ Pin
Nelek17-Jun-07 22:09
protectorNelek17-Jun-07 22:09 
GeneralRe: How to make Intelligent connectors using VC++ Pin
whatitis17-Jun-07 23:34
whatitis17-Jun-07 23:34 
GeneralRe: How to make Intelligent connectors using VC++ Pin
Nelek18-Jun-07 0:06
protectorNelek18-Jun-07 0:06 
GeneralRe: How to make Intelligent connectors using VC++ Pin
whatitis18-Jun-07 18:37
whatitis18-Jun-07 18:37 
Questionhow to submit a document in mysql Pin
p_17-Jun-07 18:48
p_17-Jun-07 18:48 
QuestionUnable to start program on VC++ Pin
Tuongnd17-Jun-07 17:35
Tuongnd17-Jun-07 17:35 

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.