title: C++ into C# pointers to a struct inside a struct of same type
body: <p>I'm trying to convert some C++ into C# for a personal learning project. </p>
  
  <p>Below you will see my C++ and then my attempt at converting it into C# using Unity classes like Vector3.</p>
  
  <p>My question:</p>
  
  <p>How do I handle pointers to a struct inside a struct of the same type?</p>
  
  <p>As far as I can tell it's not possible (HexTri m_nbAB, m_nbBC, m_nbCA;) </p>
  
  <p>Do I need to use a class instead ?</p>
  
  <p>.h file</p>
  
  <pre><code>struct HexTri;
  
  
  struct HexTile
  {
      HexTile( Imath::V3f p );    
  
      Imath::V3f m_vertPos;       
      Imath::V3f m_nrm;
      enum {
          Terrain_WATER,
          Terrain_DESERT,
          Terrain_GRASSLAND,
          Terrain_FOREST,
          Terrain_MOUNTAIN
      };
      int m_terrain;
      std::vector&lt;HexTri*&gt; m_hextri;  
  };
  
  struct HexTri
  {
      HexTri( size_t a, size_t b, size_t c );
  
      size_t m_hexA, m_hexB, m_hexC;
      HexTri *m_nbAB, *m_nbBC, *m_nbCA;
      union {
          size_t m_newvert;
          float m_angle;
      } m_tmp;
  };
  </code></pre>
  
  <p>.cpp file</p>
  
  <pre><code>HexTile::HexTile( Imath::V3f p ) :
      m_vertPos( p )
  {
      m_terrain = HexTile::Terrain_DESERT;
      m_nrm = p.normalize();
  }
  
  HexTri::HexTri( size_t a, size_t b, size_t c) :
      m_hexA( a ), m_hexB( b ), m_hexC( c )
  {
      m_nbAB = NULL;
      m_nbBC = NULL;
      m_nbCA = NULL;
  }
  </code></pre>
  
  <p>Here is my C# conversion so far</p>
  
  <pre><code>using System.Collections;  
  using System.Collections.Generic;
  using UnityEngine;
  
  public struct HexTile
  {
      private Vector3 _position;
      public Vector3 Position        
      {
          get
          {
              return _position;
          }
          set
          {
              _position = value;
          }
      }
      private Vector3 _normal;
      public Vector3 Normal        
      {
          get
          {
              return _normal;
          }
          set
          {
              _normal = value;
          }
      }
      enum terrain{
          Terrain_WATER,
          Terrain_DESERT,
          Terrain_GRASSLAND,
          Terrain_FOREST,
          Terrain_MOUNTAIN
      };
      List&lt;HexTri&gt; hextri;
  
      public HexTile( Vector3 position, Vector3 normal)
      {
          // Defaults 
          _position =  new Vector3(0,0,0); 
          _normal =  new Vector3(0,0,0);
          hextri = new List&lt;HexTri&gt;();
  
          // Initilize with value
          Position = position;
          Normal = normal;
      }
  }
  
  public struct HexTri
  {    
  
      private int _hexA;   
      public int HexA        
      {
          get
          {
              return _hexA;
          }
          set
          {
              _hexA = value;
          }
      }
      private int _hexB;  
      public int HexB        
      {
          get
          {
              return _hexB;
          }
          set
          {
              _hexB = value;
          }
      }
      private int _hexC;    
      public int HexC        
      {
          get
          {
              return _hexC;
          }
          set
          {
              _hexC = value;
          }
      }
  
      // Q1 No pointers, cant do this
      HexTri m_nbAB, m_nbBC, m_nbCA;  //?? 
      public HexTri( int a, int b, int c) 
      {
          // Defaults 
          _hexA = -1;//??
          _hexB = -1;//??
          _hexC = -1;//??
  
          // Initilize with value
          HexA = a;
          HexB = b;
          HexC = c;
      }
  }
  </code></pre>