Answer Posted / md. nasim ahmed
The conventional polymorphism approach can also be used to reach the desired result of handling different class object with same set of methods. But the problem is the driver (main/module) must handle the creation of type of object.
CBase *bptr=new CChild();
bptr->method1();
----
The Factory design pattern ease the programming effort to write the driver program as the creation of object is handled by base class only(factory class).
CBase *bptr= CBase::make_object(chioce);
----
Now refer http://sourcemaking.com/design_patterns/factory_method/cpp/1
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Why do we need singleton pattern?
What are the benefits of the proxy in the design pattern?
Which design patterns have you used in your project ?
Why singleton beans are not thread safe?
What are the examples of the behavioral design patterns?
What is mvp design pattern?
What is the creational design pattern?
What non-visual coding tools are available for web design?
What are the types of participants of the prototype design pattern you will get?
Is singleton scope thread safe?
Shall we use abstract classes or interfaces in policy / strategy design pattern?
Suppose we have file(ps), dont know how many records are there. Move half of the records to 2 files. How can we do?
What is the difference between builder and composite?
What is the singleton design pattern?
What is the difference between factory and builder design pattern?