title: Can I use ioc container for function not constructor?
body: <p>This is my main class:</p>
  <pre><code>class Human{
  public:
      Human(IHat *hat){
          hat-&gt;ChooseHat();
      }
  };
  </code></pre>
  <p>Here is classes that are about hats:</p>
  <pre><code>class IHat{
  public:
      virtual void ChooseHat() = 0;
  };
  
  class PirateHat : public IHat{
  public:
      void ChooseHat() override{
          std::cout &lt;&lt; &quot;Tamagochi has pirate hat&quot; &lt;&lt; std::endl;
      }
  };
  
  class Beret : public IHat{
  public:
      void ChooseHat() override{
          std::cout &lt;&lt; &quot;Tamagochi has beret&quot; &lt;&lt; std::endl;
      }
  };
  </code></pre>
  <p>I use <em><strong>ioc container</strong></em> from <strong>boost::di</strong> :</p>
  <pre><code>auto set1 = boost::di::make_injector(
              boost::di::bind&lt;IHat&gt;().to&lt;PirateHat&gt;(),
      );
  
      auto human = set1.create&lt;Human&gt;();
  </code></pre>
  <p>Can I create appropriate <em><strong>ioc container</strong></em> with <strong>boost::di</strong> but for function <strong>ChooseClothes</strong> not for constructor. For example:</p>
  <pre><code>class Human{
  public:
      void ChooseClothes(IHat *hat){
          hat-&gt;ChooseHat();
      }
  };
  
  
  </code></pre>