title: error C2259: cannot instantiate abstract class; or "how exactly should i be using virtual functions here?"
body: <p>this involves some pretty tricky inheritance, but bear with me here.
  My question isn't so much a specific error, but just "how would i do this specifically?"</p>
  
  <p>the idea is to have an abstract base class Food (note that this are all oversimplified for the question)</p>
  
  <pre class="lang-cpp prettyprint-override"><code>//parent of Animal
  //parent of Plant
  //~Food()
  //Food()
  #pragma once
  
  class Food
  {
  public:
      Food(){}
      ~Food(){}
  
  
  
  };
  </code></pre>
  
  <p>from that comes class animal and plants. i'm not too worried about plant right now
  Animal needs to have the virtual functions Hunt and Eat</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#pragma once
  #include "Food.h"
  
  
  class Animal : public Food
  {
  //eat() which accepts a Food* type as an argument. it is an abstract virtual in this class, it has the form
  //bool eat(Food* food)
  
  //hunt() which accepts an stl list of Food* pointers to Food type objects. the food list is declared globally in main and passed here. it has the form
  //hunt(list&lt;Food*&gt; &amp;foodlist)
  };
  </code></pre>
  
  <p>from that comes many more classes; Herbivore, Carnivore, Omnivore (which inherits from carnivore and herbivore). this is herbivore</p>
  
  <pre class="lang-cpp prettyprint-override"><code>//Child of Animal
  //Parent of Lemur, Koala, Squirrel, Omnivore
  
  //~Herbivore()
  //hunt(list&lt;Food*&amp;foodList):bool (only eats plant types)
  #pragma once
  #include "Animal.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;list&gt;
  using namespace std;
  
  class Herbivore : public virtual Animal
      {
      public:
  
          Herbivore() {}
          ~Herbivore(){}
          //eat() and hunt() are probably virtual here as well, as they aren't used directly, only the lower classes directly access them
  
  
  };
  </code></pre>
  
  <p>and from those are the bottom most child classes, and they all have roughly this form. this is a Squirrel</p>
  
  <pre class="lang-cpp prettyprint-override"><code>//child of Herbivore
  //leaf node
  
  #pragma once
  #include "Animal.h"
  #include "Herbivore.h"
  
  class Squirrel : public Herbivore
  { 
  
          //bool eat() is fully defined here instead of being virtual.
          //bool hunt() is fully defined here instead of being a virtual.
  
         //both have the same argument lists as the virtuals in Animal
  
  
  
  };
  </code></pre>
  
  <p>and here's main</p>
  
  <pre class="lang-cpp prettyprint-override"><code>list&lt;Food*&gt; Food_list; //global list of Food items that will be passed to hunt()
  int main()
  {
  
      list&lt;Food*&gt;::iterator it = Food_list.begin();
  
      (*it)-&gt;eat(*it); //passing the iterator to itself as a test. this seems to work ok
      (*it)-&gt;hunt(Food_list); //however this, in my code, refuses to work for a few reasons
  
  };
  </code></pre>
  
  <p>so basically everything inherits from food...but this is a bad thing.</p>
  
  <p>i've tried several things with the following problems</p>
  
  <p>i tried the initial version of the virtual functions in Animal, and nothing in food, it complained that Food has no function hunt</p>
  
  <pre><code>error C2039: 'hunt' : is not a member of 'Food' 
  </code></pre>
  
  <p>....which is fair i suppose, although shouldn't it be looking at the Squirrel and not the food class?</p>
  
  <p>i tried making a pure virtual in Food for eat and hunt, and from that point on, every attempt to instantiate any kind of leaf class (like a squirrel or tiger or whatever) returned the 'cannot instantiate abstract class' error.</p>
  
  <pre><code>error C2259: 'Squirrel' : cannot instantiate abstract class
  </code></pre>
  
  <p>i tried making the eat and hunt in food less abstract, like hunt(list &amp;foodlist), but then it says "syntax error, identifier 'list' ", like it doesn't know what a list is....even after i include  in Food.h</p>
  
  <pre><code>error C2061: syntax error : identifier 'list'
  </code></pre>
  
  <p>and all of these errors are paired with the error "'Food::hunt': function does not take 1 arguments"</p>
  
  <pre><code>error C2660: 'Food::hunt' : function does not take 1 arguments
  </code></pre>
  
  <p><strong>my overall question is, how would you transpose this abstract virtual function from Animal to its leaf classes? and how exactly would you call it? basically everything i have tried as failed miserably</strong>
  *<em>don't worry about what's inside eat() or hunt(), i'm just looking for proper declaration</em>*</p>
  
  <p>this github for the project is also available here
  <a href="https://github.com/joekitch/OOP_JK_Assignment_4" rel="nofollow">https://github.com/joekitch/OOP_JK_Assignment_4</a>
  if that is desired</p>