title: C++ conversion from to non-scalar type requested
body: <p>I am trying to overload the + operator as a member function so that I can add two polynomial objects (which are linked lists) together and I keep getting an error message <code>conversion from 'Polynomial*' to non-scalar type 'std::shared_ptr&lt;Polynomial&gt;' requested</code> I don't understand what is causing this? I have declared two shared pointers for my Term objects so I don't understand why I can't do this for a polynomial object?</p>
  
  <pre><code>Polynomial Polynomial::operator+( const Polynomial &amp;other ) const
  {
      shared_ptr&lt;Polynomial&gt; result = new Polynomial();
      shared_ptr&lt;Polynomial::Term&gt; a = this-&gt;head;
      shared_ptr&lt;Polynomial::Term&gt; b = other.head;
      double sum = 0;
  
      for(a; a != nullptr; a = a-&gt;next)
      {
          for(b; b != nullptr; b = b-&gt;next)
          {
              if(a-&gt;exponent == b-&gt;exponent)
              {
                  sum = a-&gt;coeff + b-&gt;coeff;
                  result-&gt;head = shared_ptr&lt;Term&gt;(new Term( sum, a-&gt;exponent, result-&gt;head ));
                  cout &lt;&lt; "function has found like terms" &lt;&lt; endl;
              }
              else if(a-&gt;exponent != b-&gt;exponent)
              {
                  result-&gt;head = shared_ptr&lt;Term&gt;(new Term( a-&gt;coeff, a-&gt;exponent, result-&gt;head ));
                  cout &lt;&lt; "function is working" &lt;&lt; endl;
  
              }
          }
    }
    result;
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <p>void makePolynomials( shared_ptr [], int &amp;x );</p>
  
  <pre><code>int main()
     {
     shared_ptr&lt;Polynomial&gt; poly[ 100 ];
     int nPolynomials = 0;
  
     makePolynomials( poly, nPolynomials );
     makePolynomials( poly, nPolynomials );
  
     for (int j=0; j &lt; nPolynomials; j++)
        cout &lt;&lt; *(poly[j]);
  
  
      //shows that the addition operator works
      Polynomial c;
      c = *(poly[0])+*(poly[1]);
      cout &lt;&lt; c &lt;&lt; endl;
  }
  
  
  void makePolynomials( shared_ptr&lt;Polynomial&gt; poly[], int &amp;nPolynomials )
     {
     char filename[20];
     cout &lt;&lt; "Enter the filename: ";
     cin &gt;&gt; filename;
  
     ifstream infile;
     infile.open( filename );
     if (! infile.is_open()) {
        cerr &lt;&lt; "ERROR: could not open file " &lt;&lt; filename &lt;&lt; endl;
        exit(1);
        }
  
     string polynom;
     while (getline( infile, polynom ))
        {
        poly[ nPolynomials ] = shared_ptr&lt;Polynomial&gt;(new Polynomial( polynom ));
        nPolynomials++;
        }
     }
  </code></pre>