title: C++ Avoiding Global Variables and Singletons
body: <p>I have recently been trying to remove the use of singletons and global variables from my project but I am having a hard time doing so. I have somewhat devised a better alternative to the singletons and global variables but I am not sure how to handle the data once my application is terminated.</p>
  
  <p>My application needs access to a couple of things for most of the components to work properly; Some components need to access <code>static std::vector&lt;Foo*&gt; foos;</code>and others need to access <code>static std::vector&lt;Bob*&gt; bobs;</code> and some needs to access both. What I have done is created "Managers" for these vectors, a FooManager which gives access to the protected static vector to a class inheriting it and a BobManager which does the same thing for the other vector. By doing this limit the scope of these two objects. My problem is at process termination how and where do I deallocate the pointers in each vector? Multiple classes are now "Managers" of these objects. From the derived class? but what if I deallocate something while another class needs the original data? </p>
  
  <p>Basically my question is how do I avoid deleting the pointers when I shouldn't be? unique_ptr? shared_ptr? Also any other implementation of this is welcome.</p>