Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can i run MFC application created in VS 2008 on OS Windows 2000? Pin
Abhijit D. Babar11-Feb-10 21:12
Abhijit D. Babar11-Feb-10 21:12 
AnswerRe: How can i run MFC application created in VS 2008 on OS Windows 2000? Pin
kirancgi11-Feb-10 21:16
kirancgi11-Feb-10 21:16 
AnswerRe: How can i run MFC application created in VS 2008 on OS Windows 2000? Pin
Stuart Dootson11-Feb-10 21:33
professionalStuart Dootson11-Feb-10 21:33 
QuestionProject Management, long compile-times Pin
zqueezy11-Feb-10 10:10
zqueezy11-Feb-10 10:10 
AnswerRe: Project Management, long compile-times Pin
«_Superman_»11-Feb-10 17:32
professional«_Superman_»11-Feb-10 17:32 
AnswerRe: Project Management, long compile-times Pin
Chris Losinger11-Feb-10 17:46
professionalChris Losinger11-Feb-10 17:46 
AnswerRe: Project Management, long compile-times Pin
Stuart Dootson11-Feb-10 21:40
professionalStuart Dootson11-Feb-10 21:40 
QuestionStatic Member Initialization Issue [Solved] Pin
Skippums11-Feb-10 7:56
Skippums11-Feb-10 7:56 
I have a struct similar to the following:
// foo.h
template<int i>
struct foo {
public:
    static const int a;
    static const int b;
};

template<>
const int foo<3>::a = 1;
template<>
const int foo<5>::a = 2;
template<int i>
const int foo<i>::b = 3 * foo<i>::a;
Then, I attempted to execute the following:
#include <iostream>
#include "foo.h"

using namespace std;

int main() {
    cout << foo<3>::b << endl << foo<5>::b << endl;
    return 0;
}
The first time I ran this code, the code produced the result b=0 for both template instantiations, but at the time I was declaring static member b prior to a. Next, I switched the order of declaration thinking that perhaps static members are initialized in the order they are declared, just like instance members. Again, the code produced 0 for the value of static member b in both template instantiations. Then, I added a cout statement prior to the one presented in the code above to print the value of a when the template parameter i=3. This time, the output was correct and gave b=3 when i=3 and b=6 when i=5. Since then, I have been unable to get my code to break, but think there is some static initialization problem that could be lurking. Does anyone know why this happened, and how I can address it?

I am also wondering how I can move the static member initialization code out of the header file where class foo is declared. I was able to move the initialization of static member a to whatever compilation unit I wanted, but when I moved initialization of b to the other compilation unit I started receiving unresolved external linker errors. Thanks,
Sounds like somebody's got a case of the Mondays

-Jeff
modified on Thursday, February 11, 2010 3:50 PM

AnswerRe: Static Member Initialization Issue Pin
Stuart Dootson11-Feb-10 8:45
professionalStuart Dootson11-Feb-10 8:45 
GeneralRe: Static Member Initialization Issue Pin
Skippums11-Feb-10 9:23
Skippums11-Feb-10 9:23 
GeneralRe: Static Member Initialization Issue Pin
Stuart Dootson11-Feb-10 9:37
professionalStuart Dootson11-Feb-10 9:37 
GeneralRe: Static Member Initialization Issue Pin
Emilio Garavaglia11-Feb-10 21:04
Emilio Garavaglia11-Feb-10 21:04 
GeneralRe: Static Member Initialization Issue Pin
Skippums11-Feb-10 9:45
Skippums11-Feb-10 9:45 
GeneralRe: Static Member Initialization Issue Pin
Yannick Le Thanh26-Apr-10 22:10
Yannick Le Thanh26-Apr-10 22:10 
QuestionProper way to add item to ListCtrl Pin
Manmohan2911-Feb-10 7:33
Manmohan2911-Feb-10 7:33 
AnswerRe: Proper way to add item to ListCtrl Pin
Richard Andrew x6411-Feb-10 7:40
professionalRichard Andrew x6411-Feb-10 7:40 
GeneralRe: Proper way to add item to ListCtrl Pin
Manmohan2911-Feb-10 7:48
Manmohan2911-Feb-10 7:48 
AnswerRe: Proper way to add item to ListCtrl Pin
David Crow11-Feb-10 7:49
David Crow11-Feb-10 7:49 
QuestionMemory allocated between two checkpoints by a process Pin
BadJerry11-Feb-10 7:30
BadJerry11-Feb-10 7:30 
QuestionMulti Monitor Configuration in MFC/C++ Pin
krishna Srihsam11-Feb-10 7:22
krishna Srihsam11-Feb-10 7:22 
AnswerRe: Multi Monitor Configuration in MFC/C++ Pin
Emilio Garavaglia11-Feb-10 21:15
Emilio Garavaglia11-Feb-10 21:15 
AnswerRe: Multi Monitor Configuration in MFC/C++ Pin
normanS11-Feb-10 22:35
normanS11-Feb-10 22:35 
QuestionNeed to extract non-exported function of DLL Pin
glitteringsound11-Feb-10 7:22
glitteringsound11-Feb-10 7:22 
AnswerRe: Need to extract non-exported function of DLL Pin
Richard MacCutchan11-Feb-10 9:48
mveRichard MacCutchan11-Feb-10 9:48 
AnswerRe: Need to extract non-exported function of DLL Pin
Saurabh.Garg11-Feb-10 17:21
Saurabh.Garg11-Feb-10 17:21 

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.