I have written the below program to demonstrate factory design pattern out of my understanding from the study.
my Doubt is almost all the examples on internet are using interface create function as static, can this be a proper example for factory design pattern.
A proper factory should be static. This is because it should technically not require access based on individual objects. All it should do is return an object of that class's type, which could be a subclass/derived type.
std::make_shared is a popular example of a factory function in the standard library
A factory could also be a class if it needs resources.
Imagine a factory that creates sprites.
Sprites might need bitmaps, so the factory need a way to know about the bitmaps and store them.
A factory can also be abstract so that you can choose between different factories at runtime.