title: c++ return a pointer to a struct from a function
body: <p>I am trying to have a <code>struct</code> declared in my class and then return a pointer
  to that <code>struct</code> using a member function in that class, but it does not work.</p>
  
  <p>Here is my code:</p>
  
  <p>someClass.h:</p>
  
  <pre><code>class someClass
  {
  public:        
      someClass();
      sword* returnSword();        
  
      struct sword
      {
          int str;
          char name;
      };
  
      sword* m_sword;
  };
  </code></pre>
  
  <p>someClass.cpp:</p>
  
  <pre><code>#include "someClass.h"
  
  someClass::someClass()
  {
      m_sword = new sword;
  
      m_sword-&gt;name='s';
      m_sword-&gt;str=5;
  }
  
  
  someClass::sword* someClass::returnSword()
  {    
      return m_sword;    
  }
  </code></pre>
  
  <p>In case if my code is total nonsense, please explain how can I have a struct in my class, initialize it and then return a pointer from that class pointing to that struct.</p>
  
  <p>Thank you.</p>