title: No matching function for call without non-parameter constructor
body: <p>We have a template class containing another class containing template object with parameterized constructor.</p>
  
  <pre><code>template&lt;class T&gt;
  class A {
  public:
  
      class B {
      public:
          T object;
  
          B(T obj) {
              this-&gt;object = obj;
          }
      };
  
      T foo(T obj) {
          B *b = new B(obj);
          return b-&gt;object;
      }
  };
  </code></pre>
  
  <p>Also we have a class of object we want as foo() parameter:</p>
  
  <pre><code>class Item {
  public:
      int value;
  
  //  Item() {}
  //  Non-parameter constructor. Within works fine
  
      Item(int value) {
          this-&gt;value = value;
      }
  };
  </code></pre>
  
  <blockquote>
    <p><strong>Notice:</strong> Within non-parameter constructor <code>Item() {}</code> code run flawlessly, but for some reason constructor always runs once without being called explicitly.</p>
  </blockquote>
  
  <p>And here goes <code>main()</code> to call <code>a.foo()</code>:</p>
  
  <pre><code>    A&lt;Item&gt; a;
      Item item(5);
  
      cout &lt;&lt; a.foo(item).value;  //expected: 5
  </code></pre>
  
  <p>Eventually we got an error like this:</p>
  
  <pre><code>error: no matching function for call to 'Item::Item()'
      B(T obj) {
               ^
  </code></pre>
  
  <blockquote>
    <p><strong>Question:</strong> How to made code with this structure work without having non-parameter constructor in <code>Class Item {}</code>?</p>
  </blockquote>
  
  <ul>
  <li>What is the reason of that structure?</li>
  <li>I code implementation of <strong>doubly linked list</strong> and simplified such error from it into this code above.</li>
  </ul>
  
  <blockquote>
    <p>HINT: I want to make code work without changing <code>Class Item {}</code> definition because I'm provider of <code>Class A</code> and I want to resolve this case particularly.</p>
  </blockquote>
  
  <h2>SOLVED</h2>
  
  <blockquote>
    <p>Error solved by using member initialization list. Thanks to <a href="https://stackoverflow.com/users/1968182/ulrich-eckhardt">Ulrich Eckhardt</a>.</p>
  </blockquote>
  
  <pre><code>B(T obj) {
      this-&gt;object = obj;
  }
  //wrong
  
  B(T obj): object(obj) {}
  //correct
  </code></pre>