title: Shared pointer using (this) registering to an observer
body: <p>I am having a problem trying to use a shared pointer from a class that wants to register to an observer (using  ) here is the example.</p>
  
  <p>Observer.hpp</p>
  
  <pre><code>class Observer {
  virtual void update() = 0;
  }
  </code></pre>
  
  <p>Consumer.hpp</p>
  
  <pre><code>class Consumer : public Observer {
  virtual void update() override;
  }
  </code></pre>
  
  <p>Consumer.cpp</p>
  
  <pre><code>class Consumer {
  ***
  </code></pre>
  
  <p><strong>THIS IS NOT WORKING - How to do it using shared pointers??</strong></p>
  
  <hr>
  
  <pre><code>register.registerObserver(std::make_shared&lt;Observer&gt;(this));
  }
  </code></pre>
  
  <p>Register.cpp</p>
  
  <pre><code>class Register {
  void registerObserver(const std::shared_ptr&lt;Observer&gt;&amp; observer);
  }
  </code></pre>