title: Making class constructor private
body: <p>I am writing a simple garbage collector in C++. I need a singleton class GarbageCollector to deal with different types of memory.
  I used a Meyer's singleton pattern. But when I try to call instance, an error appears:</p>
  
  <pre><code> error: ‘GarbageCollector::GarbageCollector(const GarbageCollector&amp;)’ is private
      GarbageCollector(const GarbageCollector&amp;);
      ^
  </code></pre>
  
  <p>Here is the class definition.</p>
  
  <pre><code>class GarbageCollector //Meyers singleton (http://cpp-reference.ru/patterns/creational-patterns/singleton/)
  {
   public:
      static GarbageCollector&amp; instance(){
          static GarbageCollector gc; 
          return gc; 
      }   
      size_t allocated_heap_memory;
      size_t max_heap_memory;
  private:
      //Copying, = and new are not available to be used by user.
      GarbageCollector(){};
      GarbageCollector(const GarbageCollector&amp;);
      GarbageCollector&amp; operator=(GarbageCollector&amp;);
  };
  </code></pre>
  
  <p>I call the instance with the following line:
  <code>auto gc = GarbageCollector::instance();</code></p>