🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Static variable initialization

Started by
1 comment, last by Gandalf 24 years, 5 months ago
Is it allowed to initialize a static class member in the constructor in C++? Im aware of this thing: (ex. variable class::name=0), but this does not work with a vector. Gandalf the White
Gandalf the Black
Advertisement
It is, but you will re-initialize it each time you create a new instance unless you specifically code your way around it (E.g. create a static boolean "g_bInitialized", which you set to true once the static member(s) is/are initialized).

/Niels
<b>/NJ</b>
I am currently using static STL vectors in my engine, and have no problem initializing it. If I knew a way to use the greater-than and less-than symbols on this message board then I''d show you how I do it.
However, if you''re not using STL (or templates) for your vector implementation than I guess this wouldn''t help you too much

JoeG
joeG

This topic is closed to new replies.

Advertisement