Website Summary Files Commits Branches @commit @diff @stats
path: root / Polymorphism / Farm(cloneFunction)
diff options
context:
space:
mode:
1 files changed, 17 insertions, 0 deletions
-rw-r--r--Polymorphism/Farm(cloneFunction)/Cat.hpp17
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;
+ }
+};