0
Why we need prototype design pattern
Hi We have copy constructor ( shallow copy ) and user defined constructor (deep copy) . Also it works for polymorphic behaviour as well as working in this code below: With this , I believe all cases works fine and don't understand the need of prototype pattern's need and clone method it provides https://sololearn.com/compiler-playground/cMp6WtZUaJK3/?ref=app
2 Respostas
+ 2
You’re right.
Your code works.
Copy constructor, deep copy, and polymorphism — all handled.
So yes, you don’t need the Prototype pattern in your case.
But here’s why Prototype exists:
It lets you clone without knowing the exact type.
It makes code cleaner and easier to extend.
It’s better when your app deals with dynamic objects or plugins.
Bottom line:
If your system is simple, you're fine without it.
If it grows, clone() saves you from messy code.
It’s not required — it’s a tool for scaling cleanly.
0
C++