title: C++ , Vector & mysql
body: <p>I found this code from: <a href="http://www.davenicholas.me.uk/blog/view_post/29/How-to-c-mysql-mac-osx" rel="nofollow">http://www.davenicholas.me.uk/blog/view_post/29/How-to-c-mysql-mac-osx</a></p>
  
  <pre><code>#include &lt;mysql.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  
  
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  int main()
  {
  
      std::vector&lt;std::string&gt; tables;
      MYSQL_RES *result;
      MYSQL_ROW row;
      MYSQL *connection, mysql;
  
      int state;
  
      connection = mysql_real_connect(&amp;mysql,"localhost","username","password","database",0,0,0);
  
      if (connection == NULL)
      {
          std::cout &lt;&lt; mysql_error(&amp;mysql) &lt;&lt; std::endl;
  
          return tables;
      }
  
      state = mysql_query(connection, "SHOW TABLES");
      if (state !=0)
      {
          std::cout &lt;&lt; mysql_error(connection) &lt;&lt; std::endl;
          return tables;
      }
  
      result = mysql_store_result(connection);
  
      std::cout &lt;&lt; "tables: " &lt;&lt; mysql_num_rows(result) &lt;&lt; std::endl;
      while ( ( row=mysql_fetch_row(result)) != NULL )
      {
          tables.push_back(row[0]);
      }
  
      mysql_free_result(result);
  
      mysql_close(connection);
          return 0;
  }
  </code></pre>
  
  <p>But when I build it I get the error: </p>
  
  <pre><code>error: cannot convert 'std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;' to 'int' in return
  </code></pre>
  
  <p>and </p>
  
  <pre><code>error: cannot convert 'std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;' to 'int' in return
  </code></pre>