title: SFML C++ drawing into RenderWindow pure virtual function runtime failure
body: <p>Im making Label and Button classes. Label basically serves as text which is attached to Button, and Button has the texture of the button and some more stuff.</p>
  
  <p>I wanted to automate things, so you dont have to call each button's draw method separatelly so I made a ButtonManager class, which has a vector and a static draw member function.</p>
  
  <p>The problem is, that the vector contains interface class and not regular one(for future extensions of Button types).</p>
  
  <p>Before I describe problem, lets see code:</p>
  
  <p>File with basic interface for all Buttons:</p>
  
  <pre><code>class ButtonManager;
  
  class ButtonBase{
      typedef ButtonManager Manager;
  public:
      virtual int getType() = 0;
      virtual void draw(sf::RenderWindow&amp; target) = 0;
  };
  </code></pre>
  
  <p>this is very simple one</p>
  
  <p>File with ButtonManager(A bit longer):</p>
  
  <pre><code>class ButtonManager{
      typedef ButtonBase* ptr;
      static std::vector&lt;ptr&gt; container;
      inline static ptr&amp; __at(uint index)
      {
          if (index &gt; container.size())    throw std::exception("bad index");
          return container[index];
      }
  
      static void __push(const ptr&amp; Pointer)    {    container.push_back(Pointer);    }
      static void __pop()    {    container.pop_back();    }
      /*
          Private to hide them from potentional unintended push or pop
      */
  public:
      enum{
          DRAW_ALL = -1
      };
  
      static void draw(sf::RenderWindow&amp; target, uint toDraw = DRAW_ALL)
      {
          std::cout &lt;&lt; "container: " &lt;&lt; container.size() &lt;&lt; "\n";
          if (toDraw == DRAW_ALL)
              for(auto&amp; a : container)
              {
                  a-&gt;draw(target);
              }
          else
              container.at(toDraw)-&gt;draw(target);
      }
      struct ClassImpl{
          inline static ptr&amp; at(uint index)    {    return ButtonManager::__at(index);    }
          inline static void push(const ptr&amp; Pointer)    {    ButtonManager::__push(Pointer);    }
          inline static void pop()    {    ButtonManager::__pop();    }
      };
  };
  
  std::vector&lt;ButtonManager::ptr&gt; ButtonManager::container;
  </code></pre>
  
  <p>and finally, a file containg the Button itself:</p>
  
  <pre><code>class Button final : public ButtonBase{
      typedef ButtonBase parent;
  
      mutable Label label;
      mutable sf::Texture texture;
      mutable sf::Sprite buttonImage;
      mutable std::function&lt;void(Button&amp;, ButtonState/* enum class */)&gt; callBack;
  public:
      Button() {}
  
      Button(const sf::Vector2f&amp; position, const sf::Vector2f&amp; size, const std::string&amp; imagePath,\
             sf::IntRect&amp; rect/*unsued*/, std::function&lt;void(Button&amp;, ButtonState)&gt; f_ptr,\
             const Label&amp; _label) : label(_label), callBack(f_ptr)
  
          //some code
          Manager::ClassImpl::push(this);
      }
  
      //copy construct
      Button(const Button&amp; b);
  
      //copy assign
      Button&amp; operator=(const Button&amp; b);
  
      //move assign
      Button(Button&amp;&amp; b);
  
      //move construct
      Button&amp; operator=(Button&amp;&amp; b);
  
      int getType()
      {
          return 1;
      }
  
      void draw(sf::RenderWindow&amp; window)
      {
          window.draw(buttonImage);
          window.draw(label.getText());
      }
  };
  </code></pre>
  
  <p>Note: I tried making ButtonManager::ptr bth ButtonBase* and std::shared_ptr, without success</p>
  
  <p>The problem I have is that when I call ButtonManager::draw(someSFMLWindow), when it tries to call a->draw(target), it will write to console:</p>
  
  <p>R6025
  - pure virtual function call</p>
  
  <p>and when I was debugging the code, the error appeared when the first line of Button::draw was called(window.draw(buttonImage)).</p>
  
  <p>Where is the problem? any hints where the problem lies?</p>