title: How to split class definition between multiple .cpp and .cu files?
body: <p>I've got a class with nested classes mixing both C++, CUDA and Thrust. I want to split member definitions across a number of files.</p>
  
  <pre><code>// In cls.h:
  #include &lt;thrust/device_vector.h&gt;
  class cls {
      class foo {   // define in foo.cu    (include "cls.h")
          kernelWrapper();
      }
      class bar {   // define in bar.cu    (include "cls.h")
          thrust::device_vector A;
          thrustStuff();
      }
      thrust::device_vector B;
      pureCPP();      // define in cls.cpp (include "cls.h")
      moreThrust();   // define in cls.cu  (include "cls.h")
  }
  </code></pre>
  
  <p>In each definition file I simply <code>#include "cls.h"</code>. However, I am currently getting an assortment of compiler errors no matter what I try, like <code>pureCPP was referenced but not defined</code>.</p>
  
  <ul>
  <li><p>I've read Thrust can only be used with <code>.cu</code> files. Because my parent class <code>cls</code> declares Thrust-type variables like <code>B</code> (and hence <code>#include</code>s <code>thrust/device_vector.h</code>), does that force all files that <code>#include</code> <code>cls.h</code> to be made into <code>.cu</code> files?</p></li>
  <li><p>Where do I use <code>extern "C"</code> in this case? I suppose <code>cls.cpp</code> would require all functions in <code>.cu</code> files to be wrapped in <code>extern "C"</code>, but what about <code>.cu</code> to <code>.cu</code> calls, like <code>moreThrust()</code> calling <code>bar::thrustStuff()</code></p></li>
  <li><p>I've also been made aware members of classes don't work with <code>extern "C"</code>, so do I have to write an <code>extern "C"</code> wrapper function for each member function?</p></li>
  </ul>
  
  <p>I'm utterly confused as to how to make this all work - what cocktail of <code>#include</code>s and <code>extern "C"</code>s do I need for each file?</p>