How access class variables in c++

前端 未结 4 1742
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 00:44

Is it possible in c++ to access class variables in other classes without creating an object. I have tried to use static, but the other class doesnt recognize my variable. I

4条回答
  •  感情败类
    2021-01-20 01:21

    I think the Singleton Pattern would help, but I'm no big fan of it. A lot better design would be to have one class take ownership of the object, and pass references to this object to the other classes.

提交回复
热议问题