title: C++ Inheritance Constructor
body: <p>I am trying to create a mammal object to call the speak function from the animal class. May I know which part I get it wrong? I am new to inheritance.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std ;
  enum COLOR { Green, Blue, White, Black, Brown } ;
  
  class Animal
  {
  public :
      Animal() : _name("unknown")
      {
          cout &lt;&lt; "constructing Animal object " &lt;&lt; _name &lt;&lt; endl ;
      }
  
      Animal (string n , COLOR c)
      {
          cout &lt;&lt; "Animal name: " &lt;&lt; n &lt;&lt; " color: " &lt;&lt; c &lt;&lt; endl;
      };
  
      ~Animal()
      {
          cout &lt;&lt; "destructing Animal object " &lt;&lt; _name &lt;&lt; endl ;
      }
      void speak() const
      {
          cout &lt;&lt; "Animal speaks " &lt;&lt; endl ;
      }
      void move() const { }
  private :
      string _name;
      COLOR _color ;
  };
  
  
  class Mammal : public Animal
  {
  public:
      Mammal (string n, COLOR c) : Animal (n, c)
      {
          cout &lt;&lt; "Animal name: " &lt;&lt; n &lt;&lt; " color: " &lt;&lt; c &lt;&lt; endl;
      }
      ~Mammal() {}
  
      void eat() const
      {
          cout &lt;&lt; "Mammal eat " &lt;&lt; endl ;
      }
  };
  int main()
  {
      Mammal m.speak();
      Animal b("lion", Green);
      cout &lt;&lt; "Program exiting …. " &lt;&lt; endl ;
      return 0;
  }
  </code></pre>
  
  <p>I do not understand why I cannot create the object m to call the speak function in animal. </p>