title: Error lvalue required as unary '&' operand
body: <p>I have a problem while creating a thread in an Object. Error is <strong>lvalue required as unary '&amp;' operand</strong></p>
  
  <p>CPP File</p>
  
  <pre><code>#include "AirQ.h"
  
  
  static int i=0;
  
  
  AirQ::AirQ(int pinNo, bool input):Sensor("AIRQUALITY", "PPM",pinNo,input) {
      threadShouldRunAQ = true;
      this-&gt;bufferLength = 256;
  
          signal(SIGINT, AirQ::signalHandler);
          airQualitySensor = new upm::Ublox6(pinNo);
  
          if (!airQualitySensor-&gt;setupTty(B9600))
              std::cerr &lt;&lt; "[ERROR][GPS] Failed to setup tty port parameters!" &lt;&lt; std::endl;
  
          try
          {
              std::thread air = std::thread(&amp;AirQ::processDataAQ(), this);
          }
          catch (std::exception e)
          {
              std::cerr &lt;&lt; "[ERROR][GPS] " &lt;&lt; e.what() &lt;&lt; std::endl;
          }
  }
  
  AirQ::~AirQ() {
      // TODO Auto-generated destructor stub
  }
  
  
  void AirQ::signalHandler(int sigNo)
  {
      if (sigNo == SIGINT)
          threadShouldRunAQ = false;
  
  }
  
  void AirQ::processDataAQ()
  {
  
      while (threadShouldRunAQ)
      {
          i++;
          if (airQualitySensor != NULL)
              if (airQualitySensor-&gt;dataAvailable())
              {
                  //TODO
              }
  
  
              usleep(100000);
      }
  }
  
  void AirQ::getData(std::string value)
  {
      this-&gt;readBuffer = value;
  }
  
  std::string AirQ::logData()
  {
      AirQ::setCollectedFlag(false);
      return this-&gt;readBuffer;
  }
  
  void AirQ::setCollectedFlag(bool flag)
  {
      this-&gt;collectedFlag = flag;
  }
  </code></pre>
  
  <p>H File</p>
  
  <pre><code>#include &lt;ublox6.h&gt;
  #include "Sensor.h"
  
  #ifndef AIRQ_H_
  #define AIRQ_H_
  
  static bool threadShouldRunAQ;
  static upm::Ublox6* airQualitySensor;
  
  
  
  class AirQ: private Sensor {
  private:
      std::string readBuffer;
      bool collectedFlag;
      size_t bufferLength;
      static void signalHandler(int);
      void processDataAQ();
  
  protected:
  
  
  public:
      AirQ(int, bool);
      virtual ~AirQ();
  
      std::string logData();
      void getData(std::string);
      void setCollectedFlag(bool);
      std::thread processingThread;
  };
  
  
  #endif /* AIRQ_H_ */
  </code></pre>
  
  <p>The error is reported in CPP File, line
  <strong>std::thread air = std::thread(&amp;AirQ::processDataAQ(), this);</strong> and i do not understand what is wrong.</p>
  
  <p>I main i create the object like this.</p>
  
  <pre><code>AirQ* test = new AirQ(0,true);
  </code></pre>
  
  <p>Any help will be appreciated.</p>
  
  <p><strong>Solution: 
  Change &amp;AirQ::processDataAQ() to &amp;AirQ::processDataAQ. The latter is a pointer-to-member-function. – Pete Becker</strong></p>