I've had this problem before and managed to fix it, but an HD failure has me back stuck with probably the same problem, after I've forgotten the solution.![]()
What I wanted to know was whether static class variables (a static map is the one I'm having particular trouble with) are guaranteed to be initialised before a class constructor is called? I've learnt a fair bit about how static members work recently but I'm still utterly stuck here.
I want to assign to a std::map<string,string>, which is a static member of, for example, class CLASS, but I can't for the life of me work out how to make it work during the construction of CLASS. After the contructor is finished, I have no problems with assigning, btw.
After trawling Google I'm tempted to think that static variables can sometimes be initialised after the constructor is finished. Is that right? Like I said, I have sorted this out before, but now I think that it was just luck that the compiler organised initialisation differently before because I'm pretty sure that the code should work. By that, I mean that a super cut-down version of the solution (which I think is set out in the above link) works, but after adding a load of extra functionality - which should be insulated from the functions/variables causing this problem - it disintegrates.
Does this ring a bell with anyone? God, I hope it does.
Cheers



LinkBack URL
About LinkBacks



