title: C++ "Variable not declared in this scope" - again
body: <p>I guess this is a really simple question and, probably, one that has been answered several times over. However, I really do suck at C++ and have searched to no avail for a solution.
  I would really appreciate the help.</p>
  
  <p>Basically:</p>
  
  <pre><code>#ifndef ANIMAL_H
  #define ANIMAL_H
  
  class Animal 
  {
   public:
    void execute();
    void setName(char*);
    Animal();
    virtual ~Animal(); 
  
   private:
    void eat();
    virtual void sleep() = 0;
  
   protected:
    char* name;
  };
  
  class Lion: public Animal 
  {
   public:
    Lion();
  
   private:
    virtual void sleep();
  };
  
  
  
  class Pig: public Animal 
  {
   public:
    Pig();
  
   private:
    virtual void sleep();
  };
  
  
  
  class Cow: public Animal
  {
   public:
    Cow();
  
   private:
  
    virtual void sleep();
  };
  
  #endif
  </code></pre>
  
  <p>Is the header file, where:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Animal.h"
  
  using namespace std;
  
  Animal::Animal()
  {
   name = new char[20];
  }
  Animal::~Animal()
  {
   delete [] name;
  }
  
  void setName( char* _name )
  {
   name = _name;
  }
  
  void Animal::eat() 
  {
   cout &lt;&lt; name &lt;&lt; ": eats food" &lt;&lt; endl;
  }
  void Animal::execute() 
  {
   eat();
   sleep();
  }
  
  
  Lion::Lion()
  {
   name = new char[20];
  }  
  void Lion::sleep()
  {
   cout &lt;&lt; "Lion: sleeps tonight" &lt;&lt; endl;
  }
  
  
  Pig::Pig()
  {
   name = new char[20];
  }   
  void Pig::sleep()
  {
   cout &lt;&lt; "Pig: sleeps anytime, anywhere" &lt;&lt; endl;
  }
  
  
  Cow::Cow()
  {
   name = new char[20];
  }
  void Cow::sleep()
  {
   cout &lt;&lt; "Cow: sleeps when not eating" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>is the C file.
  As you can see, really simple stuff, but, I get the: "error: ‘name’ was not declared in this scope" whenever I try to compile.</p>
  
  <p>It compiles if I comment out the setName method. Iv tried setting 'name' to public and still get the same error. I have also tried using "this->name = _name" in setName(), which results in "invalid use of ‘this’ in non-member function".</p>
  
  <p>I don't know what else to search for. Thanks in advance.</p>