title: Member function of a C++ object as a CUDA __global__ function
body: <p>I have a base class:</p>
  
  <pre><code>  template &lt;class T&gt; 
    class A{
           public:
             // some data
             T data;
             //some functions like constructs etc.
              ...
             // one virtual function
             virtual void evaluate() = 0;
  
     }
  </code></pre>
  
  <p>and a derived class:</p>
  
  <pre><code> template &lt;class T&gt; 
   class B:public A&lt;T&gt;{
            public:
            // some functions like constructors etc.
            virtual void evaluate();
            __global__ void function2();   // **** error message
  
   } 
  </code></pre>
  
  <p>Also, I have  </p>
  
  <pre><code> template &lt;class T&gt; void
   B&lt;T&gt;::evaluate()
   { 
      dim3 grid(1);dim3 block(1);  
      void function2&lt;&lt;&lt;grid,block&gt;&gt;&gt;();
   }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>template &lt;class T&gt;  __global__ void B&lt;T&gt;::function2() // **** error message 
  {
     // computation here
  }
  </code></pre>
  
  <p>so essentially I have a member function of a derived class which I would like to execute in a parallel fashion on the device. </p>
  
  <p>Unfortunately, I get the error:</p>
  
  <pre><code>error : illegal combination of memory qualifiers on the lines :
  
  1&gt; __global__ void function2();   // **** error message
  
  2&gt; template &lt;class T&gt;  __global__ void B&lt;T&gt;::function2() // **** error message
  </code></pre>
  
  <p>I am new to CUDA. It would be very kind if someone points me to my error. I am developing on Visual Studio 2010.</p>