prototypepattern

Design Patterns/Creational Patterns

Prototype Pattern (C++)

Prototype Pattern (C++) 목적 현재 객체를 복사하여 (속성값이 동일한 또는 거의 유사한)새로운 객체를 생성한다. java에서 clonnable 인터페이스(아래의 prototype class)와 동일하다. clone함수를 구현할 때 얕은 복사를 주의해야한다. 사용 시나리오 포토샵이나 ppt에서 도형을 복사하는 시나리오가 있다. 각각의 도형은 현재 도형의 바로 옆(x축으로 +1만큼 이동)에 생성 된다. [Prototype] class ShapePrototype { public: virtual ShapePrototype* clone() = 0; }; [ConcretePrototype] class Circle : public ShapePrototype { public: Circle(int x..

자유로운 범고래
'prototypepattern' 태그의 글 목록