title: no match for ‘operator<<’ in ‘std::operator
body: <p>I am a C++ newbie.I tried out my first program here.To my eyes this program is correct.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  class mystruct
  {
      private:
          int m_a;
          float m_b;
  
      public:
          mystruct(int x, float y)
          {
                  m_a = x;
                  m_b = y;
          }
  
  };
  
  
  int main()
  {
  
          mystruct m = mystruct(5,3.14);
  
          cout &lt;&lt; "my structure " &lt;&lt; m &lt;&lt; endl;
  
          return 0;
  }
  </code></pre>
  
  <p>However I am getting sooo many errors.Can't figure out why?</p>
  
  <pre><code>cout.cpp: In function ‘int main()’:
  cout.cpp:26:29: error: no match for ‘operator&lt;&lt;’ in ‘std::operator&lt;&lt; [with _Traits = std::char_traits&lt;char&gt;]((* &amp; std::cout), ((const char*)"my structure ")) &lt;&lt; m’
  cout.cpp:26:29: note: candidates are:
  /usr/include/c++/4.6/ostream:110: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;]
  /usr/include/c++/4.6/ostream:110:7: note:   no known conversion for argument 1 from ‘mystruct’ 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.6/ostream:119: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;]
  /usr/include/c++/4.6/ostream:119:7: note:   no known conversion for argument 1 from ‘mystruct’ 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.6/ostream:129: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;]
  /usr/include/c++/4.6/ostream:129:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘std::ios_base&amp; (*)(std::ios_base&amp;)’
  /usr/include/c++/4.6/ostream:167: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;]
  /usr/include/c++/4.6/ostream:167:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘long int’
  /usr/include/c++/4.6/ostream:171: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;]
  /usr/include/c++/4.6/ostream:171:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘long unsigned int’
  /usr/include/c++/4.6/ostream:175: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;]
  /usr/include/c++/4.6/ostream:175:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘bool’
  /usr/include/c++/4.6/bits/ostream.tcc:93: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;]
  /usr/include/c++/4.6/bits/ostream.tcc:93:5: note:   no known conversion for argument 1 from ‘mystruct’ to ‘short int’
  /usr/include/c++/4.6/ostream:182: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;]
  /usr/include/c++/4.6/ostream:182:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘short unsigned int’
  /usr/include/c++/4.6/bits/ostream.tcc:107: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;]
  /usr/include/c++/4.6/bits/ostream.tcc:107:5: note:   no known conversion for argument 1 from ‘mystruct’ to ‘int’
  /usr/include/c++/4.6/ostream:193: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;]
  /usr/include/c++/4.6/ostream:193:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘unsigned int’
  /usr/include/c++/4.6/ostream:202: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;]
  /usr/include/c++/4.6/ostream:202:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘long long int’
  /usr/include/c++/4.6/ostream:206: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;]
  /usr/include/c++/4.6/ostream:206:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘long long unsigned int’
  /usr/include/c++/4.6/ostream:211: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;]
  /usr/include/c++/4.6/ostream:211:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘double’
  /usr/include/c++/4.6/ostream:215: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;]
  /usr/include/c++/4.6/ostream:215:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘float’
  /usr/include/c++/4.6/ostream:223: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;]
  /usr/include/c++/4.6/ostream:223:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘long double’
  /usr/include/c++/4.6/ostream:227: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;]
  /usr/include/c++/4.6/ostream:227:7: note:   no known conversion for argument 1 from ‘mystruct’ to ‘const void*’
  /usr/include/c++/4.6/bits/ostream.tcc:121: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;]
  /usr/include/c++/4.6/bits/ostream.tcc:121:5: note:   no known conversion for argument 1 from ‘mystruct’ to ‘std::basic_ostream&lt;char&gt;::__streambuf_type* {aka std::basic_streambuf&lt;char&gt;*}’
  /usr/include/c++/4.6/bits/basic_string.h:2693: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;)
  /usr/include/c++/4.6/ostream:451: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)
  /usr/include/c++/4.6/ostream:456: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)
  /usr/include/c++/4.6/ostream:462: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)
  /usr/include/c++/4.6/ostream:468: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)
  /usr/include/c++/4.6/ostream:473: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)
  /usr/include/c++/4.6/ostream:493: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*)
  /usr/include/c++/4.6/bits/ostream.tcc:323: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*)
  /usr/include/c++/4.6/ostream:510: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*)
  /usr/include/c++/4.6/ostream:523: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*)
  /usr/include/c++/4.6/ostream:528: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*)
  </code></pre>