title: Partial class definition on C++?
body: <p>Anyone knows if is possible to have partial class definition on C++ ?</p>
  
  <p>Something like:</p>
  
  <p>file1.h:</p>
  
  <pre>  
  class Test {
      public:
          int test1();
  };
  </pre>
  
  <p>file2.h:  </p>
  
  <pre>
  class Test {
      public:
          int test2();
  };
  </pre>
  
  <p>For me it seems quite useful for definining multi-platform classes that have common functions between them that are platform-independent because inheritance is a cost to pay that is non-useful for multi-platform classes.</p>
  
  <p>I mean you will never have two multi-platform specialization instances at runtime, only at compile time. Inheritance could be useful to fulfill your public interface needs but after that it won't add anything useful at runtime, just costs. </p>
  
  <p>Also you will have to use an ugly #ifdef to use the class because you can't make an instance from an abstract class:</p>
  
  <pre>
  class genericTest {
      public:
          int genericMethod();
  };
  </pre>
  
  <p>Then let's say for win32:</p>
  
  <pre>
  class win32Test: public genericTest {
      public:
          int win32Method();
  };
  </pre>
  
  <p>And maybe:</p>
  
  <pre>
  class macTest: public genericTest {
      public:
          int macMethod();
  };
  </pre>
  
  <p>Let's think that both win32Method() and macMethod() calls genericMethod(), and you will  have to use the class like this:</p>
  
  <pre>
   #ifdef _WIN32
   genericTest *test = new win32Test();
   #elif MAC
   genericTest *test = new macTest();
   #endif
  
   test->genericMethod();
  </pre>
  
  <p>Now thinking a while the inheritance was only useful for giving them both a genericMethod() that is dependent on the platform-specific one, but you have the cost of calling two constructors because of that. Also you have ugly #ifdef scattered around the code.</p>
  
  <p>That's why I was looking for partial classes. I could at compile-time define the specific  platform dependent partial end, of course that on this silly example I still need an ugly #ifdef inside genericMethod() but there is another ways to avoid that.</p>