Initialization of object static members

前端 未结 7 1068
余生分开走
余生分开走 2021-01-24 21:51

Static members confuse me sometimes. I understand how to initialize a simple built in type such as int with something along the lines of int myClass::statVar

7条回答
  •  执念已碎
    2021-01-24 22:20

    Is it only a one function that needs RandomGenerator? You may do this in this way:

    int myClass::foo() { static RandomGenerator itsGenerator = RandomGenerator::Randomize() ... }

提交回复
热议问题