title: CUDA kernel as member function of a class
body: <p>I am using CUDA 5.0 and a Compute Capability 2.1 card.</p>
  
  <p>The question is quite straightforward: Can a kernel be part of a class?
  For example:</p>
  
  <pre class="lang-c prettyprint-override"><code>class Foo
  {
  private:
   //...
  public:
   __global__ void kernel();
  };
  
  __global__ void Foo::kernel()
  {
   //implementation here
  }
  </code></pre>
  
  <p>If not then the solution is to make a wrapper function that is member of the class and calls the kernel internally?</p>
  
  <p>And if yes, then will it have access to the private attributes as a normal private function?</p>
  
  <p>(I'm not just trying it and see what happens because my project has several other errors right now and also I think it's a good reference question. It was difficult for me to find reference for using CUDA with C++. Basic functionality examples can be found but not strategies for structured code.)</p>