diff options
Rename Polymorphism/Figures/Farm(cloneFunction)/Cat.hpp to Polymorphism/Farm(cloneFunction)/Cat.hpp
1 files changed, 17 insertions, 0 deletions
| -rw-r--r-- | Polymorphism/Farm(cloneFunction)/Cat.hpp | 17 |
diff --git a/Polymorphism/Farm(cloneFunction)/Cat.hpp b/Polymorphism/Farm(cloneFunction)/Cat.hpp new file mode 100644 index 0000000..3b11228 --- /dev/null +++ b/Polymorphism/Farm(cloneFunction)/Cat.hpp @@ -0,0 +1,17 @@ +#include "Animal.hpp"
+
+class Cat : public Animal
+{
+public:
+ Cat(String name) :Animal(name)
+ {}
+ Animal* clone()
+ {
+ Animal* copy = new Cat(*this);
+ return copy;
+ }
+ void Roar()
+ {
+ std::cout << "meow meow" << std::endl;
+ }
+};
|
