Implementation of a Kennel I need a code review for the following question:


  Using C++ object oriented design, provide the implementation of Kennel
  so that:
  
  
  The method AddCat() adds a Cat to the Kennel, providing its name.
  The method AddDog() adds a Dog to the Kennel, providing its name.
  The method RollCall() prints the Animal's name and sound to stdout:
  
  
  Cats identify themselves by printing "Meow" to stdout.
  Dogs identify themselves by printing "Woof" to stdout.
  
  




Kennel .h

    #pragma once
    #ifndef KENNEL_H
    #define KENNEL_H

    #include &lt;string&gt;
    #include &lt;iostream&gt;
    #include &lt;vector&gt;

    class Kennel
    {

    public:
        Kennel() { };
        virtual ~Kennel();
        void AddCat(const std::string &amp; name);
        void AddDog(const std::string &amp; name);
        void RollCall();
        virtual void makeSound(std::string name) { }

    private:
        std::vector &lt;Kennel*&gt; KennelList;
    protected:
        std::string name;

    };

    //Dog inherits Kennel
    class Dog :public Kennel
    {
    public:
        Dog(std::string dogName)
        {
            name = dogName;
        }
        ~Dog() { };
        void makeSound(std::string name)
        {
            std::cout &lt;&lt; name &lt;&lt; " says Woof" &lt;&lt; std::endl;
        };
    };

    //Cat inherits Kennel
    class Cat :public Kennel
    {
    public:
        Cat(std::string catName)
        {
            name = catName;
        }
        ~Cat() { };
        void makeSound(std::string name)
        {
            std::cout &lt;&lt; name &lt;&lt; " says Meow" &lt;&lt; std::endl;
        };
    };


    #endif


Kennel.cpp

    #include "Kennel.h"


    Kennel::~Kennel()
    {
        for (auto i : KennelList)
        {
            delete i;
        }
    }

    void Kennel::AddCat(const std::string &amp; name)
    {
        KennelList.push_back(new Cat(name));
    }

    void Kennel::AddDog(const std::string &amp; name)
    {
        KennelList.push_back(new Dog(name));
    }

    void Kennel::RollCall()
    {
        for (unsigned int i = 0; i &lt; KennelList.size(); ++i)
        {
            KennelList[i]-&gt;makeSound(KennelList[i]-&gt;name);
        }
    }


main

#include "Kennel.h"
    int main()
    {
    Kennel kennel;

    kennel.AddCat("Garfield");
    kennel.AddDog("Odie");
    kennel.AddDog("Pluto");
    kennel.AddCat("Felix");
    kennel.AddCat("Sylvester");
    kennel.AddCat("Scratchy");
    kennel.AddDog("Scooby Doo");
    kennel.AddCat("Puss in Boots");
    kennel.AddDog("Goofy");
    kennel.AddDog("Old Yeller");

    kennel.RollCall();
}
Think of the phrase : public to mean "is a".

A dog is not a kennel, nor is a cat, so Dog and Cat should not inherit from Kennel. You need a class called Animal. Cats and dogs are animals, so Cat and Dog should derive from Animal. Animals are contained in a kennel.