title: What is a callable object in C++?
body: <p>I'm currently studying boost threads. And I came across that the thread class has a constructor that accepts callable objects. What are callable objects? </p>
  
  <pre><code>class CallableClass
  {
  private:
      // Number of iterations
      int m_iterations;
  
  public:
  
      // Default constructor
      CallableClass()
      {
          m_iterations=10;
      }
  
      // Constructor with number of iterations
      CallableClass(int iterations)
      {
          m_iterations=iterations;
      }
  
      // Copy constructor
      CallableClass(const CallableClass&amp; source)
      {
          m_iterations=source.m_iterations;
      }
  
      // Destructor
      ~CallableClass()
      {
      }
  
      // Assignment operator
      CallableClass&amp; operator = (const CallableClass&amp; source)
      {
          m_iterations=source.m_iterations;
          return *this;
      }
  
      // Static function called by thread
      static void StaticFunction()
      {
          for (int i=0; i &lt; 10; i++)  // Hard-coded upper limit
          {
              cout&lt;&lt;i&lt;&lt;"Do something in parallel (Static function)."&lt;&lt;endl;
              boost::this_thread::yield(); // 'yield' discussed in section 18.6
          }
      }
  
      // Operator() called by the thread
      void operator () ()
      {
          for (int i=0; i&lt;m_iterations; i++)
          {
              cout&lt;&lt;i&lt;&lt;" - Do something in parallel (operator() )."&lt;&lt;endl;
              boost::this_thread::yield(); // 'yield' discussed in section 18.6
          }
      }
  
  };
  </code></pre>
  
  <p>How does this become a callable object? Is it because of the operator overloaded or the constructor or something else?</p>