- Gof/FactoryMethod . . . . 7 matches
Parameterized factory method는 Product를 상속받은 MyProduct와 YourProduct상에서일반적으로 다음과 같은 형태를 가진다.
if (id == MINE) return new MyProduct;
예를 들어서 sub클래스 MyCreator는 MyProduct와 YouProduct를 바꾸고, 새로운 TheirProduct Sub클래스를 지원할수 있다.
if (id == YOURS) return new MyProduct;
// YouProduct와 MyProduct 교환
class MyProduct : public Product {
MyProduct();