Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    Have you considered dependency injection? BTW: It's pretty much irrelevant that you are using C++ here, you'd face the same issues and have the same solutions in many other languages. Commented Apr 4, 2018 at 4:52
  • Just do what you described. Commented Apr 4, 2018 at 5:01
  • Ulrich, Thanks for the suggestion on dependency injection, which I need to learn. I need to use C or C++ as the target platform is an embedded platform with very limited memory. Commented Apr 4, 2018 at 5:04
  • If you do not need to access these objects globally from any part of your code, then dependency injection is the way to go. If you do need global access, then you may consider using a service locator, read more here: gameprogrammingpatterns.com/service-locator.html Commented Apr 4, 2018 at 5:04