Initialization of object static members

前端 未结 7 1073
余生分开走
余生分开走 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:33

    If only myClass needs the RandomGenerator, then:

    myClass::myClass()
    {
        itsGenerator.Randomize();
    }
    

    Does it matter if you re-randomize your random generator for each object? I'm assuming no ;-)

提交回复
热议问题