title: c++ .hpp and .cpp
body: <p>Can someone tell me what is the correct way to create a .hpp and .cpp that includes classes, subclasses and methods? Do I have to use <code>export "C" firstClass* create_object { return new firstClass; }</code>? (I am working in C++.) Should I have <code>file.hpp</code> or <code>file.h</code>?</p>
  
  <pre><code>#include &lt;string&gt;
  
  //public ?? how can i have this?
  class firstClass
  {
  public:
      firstClass();
  
      class secondClass
      {
      public:
          secondClass();
          std::string name;
          virtual std::string method1();
      } *sec;
  
      virtual void DoSomething();
  } *first;
  
  // And for a private class?
  
  class private *priv;
  </code></pre>
  
  <p>in file.cpp</p>
  
  <pre><code>#include file.hpp
  firstClass::firstClass()
  {
      sec = new firstClass::secondClass();
  }
  
  std::string firstClass::secondClass::method1()
  {
      //code
  }
  </code></pre>
  
  <p>And now if I have to <code>extern</code> an object for each class/subclass? It is necessary if I want to create an .so file and use dlsym and dlopen to access classes, subclasses and methods, modify values, send a reference to a specific method? Thanks!</p>
  
  <pre><code>extern "C" firstClass* create_object()
  {return new firstClass}
  extern "C" secondClass* create_object()
  {return new secondClass}
  </code></pre>