title: No viable conversion from Singleton to nested Listener *
body: <p>Couldn't find the solution elsewhere on site but please point me elsewhere incase I'm wrong. </p>
  
  <p>Say I wanted to listen to a button and do something depending on its size from a singleton object...</p>
  
  <p>I would create a button object with a nested listener...</p>
  
  <pre><code>class ScaledButton
  {
  public:
      ScaledButton(const int buttonSize) : _buttonSize(buttonSize){}
  
      ~ScaledButton(){}
  
      /** Nested Listener calss*/
      class Listener
      {
      public:
          virtual ~Listener() {}
  
          /** Would be called on button click for example... */
          virtual void scaledButtonChanged(const int buttonSize) = 0;
      };
  
      void addListener (Listener* listener)
      {
          _listener = listener;
      }
  
  private:
      ScaledButton();
      int _buttonSize;
      Listener* _listener; ///&lt; POINTER TO THE LISTENER
  };
  </code></pre>
  
  <p>Then create my singleton that inherits publicly from the listener...</p>
  
  <pre><code>class Singleton : public ScaledButton::Listener ///&lt; PUBLIC INHERITANCE HERE
  {
  public:
      static Singleton&amp; getInstance()
      {
          static Singleton instance;
          return instance;
      }
  
      virtual void scaledButtonChanged(const int buttonSize) override
      {
          //... do something depending on the size of the button!!!!!!
      }
  
  private:
      Singleton(){} // Must call get instance.
      Singleton(const Singleton&amp;); // Cannot copy
      void operator= (const Singleton&amp; args); // Cannot copy
  };
  </code></pre>
  
  <p>And within main add the listener like so.. </p>
  
  <pre><code>int main()
  {
      Singleton&amp; mySingleton = Singleton::getInstance();
  
      ScaledButton myButton(5);
      myButton.addListener(mySingleton); ///&lt; ERROR HERE!
  
      return 0;
  }
  </code></pre>
  
  <p>However the listener cannot be added with the error: </p>
  
  <p>*No viable conversion from 'Singleton' to 'ScaledButton::Listener <em>'</em></p>
  
  <p>My hunch is that it is to do with the conflict of using a singleton with a reference and Listener with a pointer: or the inheritance of the pure virtual Listener class.</p>
  
  <p>My C++ skills aren't quite sharp enough to solve the error despite trying various singleton implementations (such as using a global ptr). Any suggestions? </p>
  
  <p>On Mac OS using a clang compiler. </p>