title: Interacting with C++ classes from Swift
body: <p>I have a significant library of classes written in C++.  I'm trying to make use of them through some type of bridge within Swift rather than rewrite them as Swift code.  The primary motivation is that the C++ code represents a core library that is used on multiple platforms.  Effectively, I'm just creating a Swift based UI to allow the core functionality to work under OS X.</p>
  
  <p>There are other questions asking, "How do I call a C++ function from Swift."  This is <em>not</em> my question.  To bridge to a C++ function, the following works fine:</p>
  
  <p><strong>Define a bridging header through "C"</strong></p>
  
  <pre><code>#ifndef ImageReader_hpp
  #define ImageReader_hpp
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
      const char *hexdump(char *filename);
      const char *imageType(char *filename);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* ImageReader_hpp */
  </code></pre>
  
  <p><strong>Swift code can now call functions directly</strong></p>
  
  <pre><code>let type = String.fromCString(imageType(filename))
  let dump = String.fromCString(hexdump(filename))
  </code></pre>
  
  <p>My question is more specific.  How can I instantiate and manipulate a <em>C++ Class</em> from within Swift?  I can't seem to find anything published on this.</p>