title: C++ class forward declaration
body: <p>When I try to compile this code, I get:</p>
  <pre><code>52 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h invalid use of undefined type `struct tile_tree_apple' 
  46 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h forward declaration of `struct tile_tree_apple' 
  </code></pre>
  <p>some part of my code:</p>
  <pre><code>class tile_tree_apple;
  
  class tile_tree : public tile
  {
        public:
            tile onDestroy() {return *new tile_grass;};
            tile tick() {if (rand()%20==0) return *new tile_tree_apple;};
            void onCreate() {health=rand()%5+4; type=TILET_TREE;};        
  };
  
  class tile_tree_apple : public tile
  {
        public:
            tile onDestroy() {return *new tile_grass;};
            tile tick() {if (rand()%20==0) return *new tile_tree;};
            void onCreate() {health=rand()%5+4; type=TILET_TREE_APPLE;}; 
            tile onUse() {return *new tile_tree;};       
  };
  </code></pre>
  <p>I dont really know what to do, I searched for the solution but I couldn't find anything simmilar to my problem... Actually, I have more classes with parent &quot;tile&quot; and It was ok before...</p>
  <p>EDIT:</p>
  <p>I decided to change all returned types to pointers to avoid memory leaks, but now I got:</p>
  <pre><code>27 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h ISO C++ forbids declaration of `tile' with no type 
  27 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h expected `;' before &quot;tick&quot;
  </code></pre>
  <p>Its only in base class, everything else is ok... Every function in tile class which return *tile has this error...</p>
  <p>Some code:</p>
  <pre><code>class tile
  {
        public:
            double health;
            tile_type type;
            *tile takeDamage(int ammount) {return this;};
            *tile onDestroy() {return this;};
            *tile onUse() {return this;};
            *tile tick() {return this};
            virtual void onCreate() {};
  };
  </code></pre>