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
What are the categories in which the design patterns can be divided?
Can we have this pattern implemented using static class?
Why do we need singleton pattern?
What is the difference between builder and composite?
What is onion architecture?
Why is singleton used?
Shall we use abstract classes or interfaces in policy / strategy design pattern?
What is the creational design pattern?
What is the difference between architecture and design?
What is the executor design pattern?
Give me example of observer design pattern?
Why is singleton bad?
What is factory method in design pattern?
What are the differences between the design patterns and the framework?
What are useful tools for developing and testing color schemes for web sites?