title: C++: How to create and use mysql connection within a class
body: <p>I'm very new in C++.  Where and how will I define the mysql connection in class definition? I'm trying to create connection in a class constructor. And close when destructor called. Just need some tips how to do it properly and how will I call it within class methods? is there something like 'this->mysql'?</p>
  
  <pre><code>class Queue {
      public:
      Queue() {  
          MYSQL *mysql = NULL; 
      ...        
          mysql = mysql_init(NULL);
          if(!mysql_real_connect(mysql, getMySqlHost().c_str(),...
    }
  
  void someFunction ( const std::string &amp; MyStr){
      mysql_query(this-&gt;mysql,MyStr.c_str());
  ...
  </code></pre>
  
  <p>and destructor:</p>
  
  <pre><code>~Queue() { mysql_close( this-&gt;mysql); }
  </code></pre>
  
  <p>im getting <code>queue.h:231:31: error: ‘class Queue’ has no member named ‘mysql’</code></p>