title: Using overloaded operator+ without assignment
body: <p>I have simple(not simple) question: Is any possibility that overloaded operator+ will be working not as we want when we won't use assignment overloaded operator?</p>
  
  <p>Example:</p>
  
  <pre><code>object a, b, c;
  //Here is some code where I add some numbers to object a and b;
  c=a+b;
  cout &lt;&lt; c;
  </code></pre>
  
  <p>And the thing is: when I'm using overloaded assingment operator, everything is fine. But without this, elements which are in c gets some random numbers. Why?</p>
  
  <p>And another question: why I can't do something like that with overloaded &lt;&lt; and + operators:</p>
  
  <pre><code>cout &lt;&lt; a+b;
  </code></pre>
  
  <p>EDIT: Here is code:</p>
  
  <pre><code>    #include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  using namespace std;
  class List;
  
  class element{
      private:
          int number;
          element* next;
          friend class List;
          friend ostream &amp; operator&lt;&lt;(ostream &amp;, List &amp;);
  
      public:
          element(int data){
              number=data;
          }
  
          int getData(){
              return number;
          }
  
  };
  
  class List{
      private:
          element* head;
          int size;
          friend ostream &amp; operator&lt;&lt;(ostream &amp;, List &amp;);
      public:
          List(){
              head=NULL;
              size=0;
          }
  
          List(const List &amp;lista){
              //cout &lt;&lt; "wyw" &lt;&lt; endl;
              //fflush(stdout);
              if (lista.size==0){
                  size=0;
                  head=NULL;
              }
              else
              {
                  size=0;
                  head=NULL;
                  element* tmp=lista.head;
                  while(tmp!=NULL){
                      cout &lt;&lt; tmp-&gt;number &lt;&lt; " ";
                      fflush(stdout);
                      this-&gt;addToList(tmp-&gt;number);
                      tmp=tmp-&gt;next;
                  }   
              }
  
          }
  
          ~List(){
              if (head!=NULL){
                  element* tmp=head;
                  element *temp;
                  while(tmp!=NULL){
                      temp=tmp-&gt;next;
                      delete tmp;
                      tmp=temp;
                  }   
                  head=NULL;
              }
          }
  
          void addToList(int data){
              element* newNode=new element(data);
              newNode-&gt;next=NULL;
              element *tmp=head;
              if (tmp!=NULL){
                  while(tmp-&gt;next!=NULL){
                      tmp=tmp-&gt;next;
                  }
                  tmp-&gt;next=newNode;
              }
              else{
                  head=newNode;
              }
              size++;
  
          }   
  
          List&amp; operator=(const List&amp; lista){
              if (&amp;lista==this) return *this;
              if (this-&gt;head!=NULL){
                  element* tmp=head;
                  element *temp;
                  while(tmp!=NULL){
                      temp=tmp-&gt;next;
                      delete tmp;
                      tmp=temp;
                  }
                  head=NULL;
              }
              if (lista.size==0){
                  size=0;
                  head=NULL;
              }
              else
              {
                  size=0;
                  head=NULL;
                  element* tmp=lista.head;
                  while(tmp!=NULL){
                      this-&gt;addToList(tmp-&gt;number);
                      tmp=tmp-&gt;next;
                  }   
              }
  
              return *this;
          }
  
          List  operator+(const List &amp;lista){
              List newList;
              element *tmp=this-&gt;head;
              while (tmp!=NULL){
                  newList.addToList(tmp-&gt;number);
                  tmp=tmp-&gt;next;
              }
              tmp=lista.head;
              while (tmp!=NULL){
                  newList.addToList(tmp-&gt;number);
                  tmp=tmp-&gt;next;
              }
              return newList;
          }
  };  
  
  
  istream &amp; operator&gt;&gt;(istream &amp;str, List &amp;lists){
      int data;
      str &gt;&gt; data;
      lists.addToList(data);
      return str;
  }
  
  ostream &amp; operator&lt;&lt;(ostream &amp;str, List &amp;lists){
      element*tmp=lists.head;
      if (tmp==NULL){
          str &lt;&lt; "List is empty" &lt;&lt; endl;
      }
      else{
          while(tmp!=NULL){
              str &lt;&lt; tmp-&gt;number &lt;&lt; "--";
              tmp=tmp-&gt;next;
          }   
          str &lt;&lt; "NULL" &lt;&lt; endl &lt;&lt; "Size of lsit: " &lt;&lt; lists.size &lt;&lt; endl;
          }
          return str;
      }
  
  
  int main(){
      List lista;
      cin &gt;&gt; lista;
      cin &gt;&gt; lista;
      List list2=lista;
      cout &lt;&lt; lista;
  cout &lt;&lt; list2;
  List c;
  //cout &lt;&lt; list2+lista; CANT DO THAT, WHY?
  c=list2+lista;
  cout &lt;&lt; c;
  return 0;
  }
  </code></pre>
  
  <p>@DrewDormann Here is error:</p>
  
  <pre><code>    lista.cpp: In function ‘int main()’:
  lista.cpp:167:7: error: no match for ‘operator&lt;&lt;’ (operand types are ‘std::ostream {aka std::basic_ostream&lt;char&gt;}’ and ‘List’)
    cout &lt;&lt; lista+list2;
         ^
  lista.cpp:167:7: note: candidates are:
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:108:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; (*)(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp;)) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(__ostream_type&amp; (*__pf)(__ostream_type&amp;))
         ^
  /usr/include/c++/4.8/ostream:108:7: note:   no known conversion for argument 1 from ‘List’ to ‘std::basic_ostream&lt;char&gt;::__ostream_type&amp; (*)(std::basic_ostream&lt;char&gt;::__ostream_type&amp;) {aka std::basic_ostream&lt;char&gt;&amp; (*)(std::basic_ostream&lt;char&gt;&amp;)}’
  /usr/include/c++/4.8/ostream:117:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;::__ios_type&amp; (*)(std::basic_ostream&lt;_CharT, _Traits&gt;::__ios_type&amp;)) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ios_type = std::basic_ios&lt;char&gt;]
         operator&lt;&lt;(__ios_type&amp; (*__pf)(__ios_type&amp;))
         ^
  /usr/include/c++/4.8/ostream:117:7: note:   no known conversion for argument 1 from ‘List’ to ‘std::basic_ostream&lt;char&gt;::__ios_type&amp; (*)(std::basic_ostream&lt;char&gt;::__ios_type&amp;) {aka std::basic_ios&lt;char&gt;&amp; (*)(std::basic_ios&lt;char&gt;&amp;)}’
  /usr/include/c++/4.8/ostream:127:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::ios_base&amp; (*)(std::ios_base&amp;)) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(ios_base&amp; (*__pf) (ios_base&amp;))
         ^
  /usr/include/c++/4.8/ostream:127:7: note:   no known conversion for argument 1 from ‘List’ to ‘std::ios_base&amp; (*)(std::ios_base&amp;)’
  /usr/include/c++/4.8/ostream:166:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(long int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(long __n)
         ^
  /usr/include/c++/4.8/ostream:166:7: note:   no known conversion for argument 1 from ‘List’ to ‘long int’
  /usr/include/c++/4.8/ostream:170:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(long unsigned int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(unsigned long __n)
         ^
  /usr/include/c++/4.8/ostream:170:7: note:   no known conversion for argument 1 from ‘List’ to ‘long unsigned int’
  /usr/include/c++/4.8/ostream:174:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(bool) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(bool __n)
         ^
  /usr/include/c++/4.8/ostream:174:7: note:   no known conversion for argument 1 from ‘List’ to ‘bool’
  In file included from /usr/include/c++/4.8/ostream:609:0,
                   from /usr/include/c++/4.8/iostream:39,
                   from lista.cpp:1:
  /usr/include/c++/4.8/bits/ostream.tcc:91:5: note: std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(short int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;]
       basic_ostream&lt;_CharT, _Traits&gt;::
       ^
  /usr/include/c++/4.8/bits/ostream.tcc:91:5: note:   no known conversion for argument 1 from ‘List’ to ‘short int’
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:181:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(short unsigned int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(unsigned short __n)
         ^
  /usr/include/c++/4.8/ostream:181:7: note:   no known conversion for argument 1 from ‘List’ to ‘short unsigned int’
  In file included from /usr/include/c++/4.8/ostream:609:0,
                   from /usr/include/c++/4.8/iostream:39,
                   from lista.cpp:1:
  /usr/include/c++/4.8/bits/ostream.tcc:105:5: note: std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;]
       basic_ostream&lt;_CharT, _Traits&gt;::
       ^
  /usr/include/c++/4.8/bits/ostream.tcc:105:5: note:   no known conversion for argument 1 from ‘List’ to ‘int’
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:192:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(unsigned int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(unsigned int __n)
         ^
  /usr/include/c++/4.8/ostream:192:7: note:   no known conversion for argument 1 from ‘List’ to ‘unsigned int’
  /usr/include/c++/4.8/ostream:201:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(long long int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(long long __n)
         ^
  /usr/include/c++/4.8/ostream:201:7: note:   no known conversion for argument 1 from ‘List’ to ‘long long int’
  /usr/include/c++/4.8/ostream:205:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(long long unsigned int) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(unsigned long long __n)
         ^
  /usr/include/c++/4.8/ostream:205:7: note:   no known conversion for argument 1 from ‘List’ to ‘long long unsigned int’
  /usr/include/c++/4.8/ostream:220:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(double) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(double __f)
         ^
  /usr/include/c++/4.8/ostream:220:7: note:   no known conversion for argument 1 from ‘List’ to ‘double’
  /usr/include/c++/4.8/ostream:224:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(float) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(float __f)
         ^
  /usr/include/c++/4.8/ostream:224:7: note:   no known conversion for argument 1 from ‘List’ to ‘float’
  /usr/include/c++/4.8/ostream:232:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(long double) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(long double __f)
         ^
  /usr/include/c++/4.8/ostream:232:7: note:   no known conversion for argument 1 from ‘List’ to ‘long double’
  /usr/include/c++/4.8/ostream:245:7: note: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(const void*) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;]
         operator&lt;&lt;(const void* __p)
         ^
  /usr/include/c++/4.8/ostream:245:7: note:   no known conversion for argument 1 from ‘List’ to ‘const void*’
  In file included from /usr/include/c++/4.8/ostream:609:0,
                   from /usr/include/c++/4.8/iostream:39,
                   from lista.cpp:1:
  /usr/include/c++/4.8/bits/ostream.tcc:119:5: note: std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__streambuf_type = std::basic_streambuf&lt;char&gt;]
       basic_ostream&lt;_CharT, _Traits&gt;::
       ^
  /usr/include/c++/4.8/bits/ostream.tcc:119:5: note:   no known conversion for argument 1 from ‘List’ to ‘std::basic_ostream&lt;char&gt;::__streambuf_type* {aka std::basic_streambuf&lt;char&gt;*}’
  lista.cpp:141:12: note: std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, List&amp;)
    ostream &amp; operator&lt;&lt;(ostream &amp;str, List &amp;lists){
              ^
  lista.cpp:141:12: note:   no known conversion for argument 2 from ‘List’ to ‘List&amp;’
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:548:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, const unsigned char*)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, const unsigned char* __s)
       ^
  /usr/include/c++/4.8/ostream:548:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘const unsigned char*’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:543:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, const signed char*)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, const signed char* __s)
       ^
  /usr/include/c++/4.8/ostream:543:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘const signed char*’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:530:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, const char*)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, const char* __s)
       ^
  /usr/include/c++/4.8/ostream:530:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘const char*’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/ostream:609:0,
                   from /usr/include/c++/4.8/iostream:39,
                   from lista.cpp:1:
  /usr/include/c++/4.8/bits/ostream.tcc:321:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, const char*)
       operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out, const char* __s)
       ^
  /usr/include/c++/4.8/bits/ostream.tcc:321:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘const char*’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:513:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, const _CharT*)
       operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out, const _CharT* __s)
       ^
  /usr/include/c++/4.8/ostream:513:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   mismatched types ‘const _CharT*’ and ‘List’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:493:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, unsigned char)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, unsigned char __c)
       ^
  /usr/include/c++/4.8/ostream:493:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘unsigned char’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:488:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, signed char)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, signed char __c)
       ^
  /usr/include/c++/4.8/ostream:488:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘signed char’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:482:5: note: template&lt;class _Traits&gt; std::basic_ostream&lt;char, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;char, _Traits&gt;&amp;, char)
       operator&lt;&lt;(basic_ostream&lt;char, _Traits&gt;&amp; __out, char __c)
       ^
  /usr/include/c++/4.8/ostream:482:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘char’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:476:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, char)
       operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out, char __c)
       ^
  /usr/include/c++/4.8/ostream:476:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   cannot convert ‘List::operator+(const List&amp;)((*(const List*)(&amp; list2)))’ (type ‘List’) to type ‘char’
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from lista.cpp:1:
  /usr/include/c++/4.8/ostream:471:5: note: template&lt;class _CharT, class _Traits&gt; std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, _CharT)
       operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out, _CharT __c)
       ^
  /usr/include/c++/4.8/ostream:471:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   deduced conflicting types for parameter ‘_CharT’ (‘char’ and ‘List’)
    cout &lt;&lt; lista+list2;
                  ^
  In file included from /usr/include/c++/4.8/string:52:0,
                   from /usr/include/c++/4.8/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8/bits/ios_base.h:41,
                   from /usr/include/c++/4.8/ios:42,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from lista.cpp:1:
  /usr/include/c++/4.8/bits/basic_string.h:2753:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_ostream&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
       operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os,
       ^
  /usr/include/c++/4.8/bits/basic_string.h:2753:5: note:   template argument deduction/substitution failed:
  lista.cpp:167:16: note:   ‘List’ is not derived from ‘const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;’
    cout &lt;&lt; lista+list2;
  </code></pre>
  
  <p>I know that this is when i'm trying to use operaotr without overloading, but here problem is that operator &lt;&lt; is overloaded.</p>