Factory method pattern: Difference between revisions

Content deleted Content added
Fixing harv/sfn errors. Please watchlist Category:Harv and Sfn no-target errors and install User:Trappist the monk/HarvErrors.js to help you spot such errors when reading and editing.
Examples: fixed weasel word
 
(3 intermediate revisions by 2 users not shown)
Line 27:
 
== Examples ==
This [[C++1423]] implementation is based on the pre C++98 implementation in the ''[[Design Patterns]]'' book.{{sfn|Gamma|Helm|Johnson|Vlissides|1995|page=122}}{{Which one|date=August 2024}}
<syntaxhighlight lang="c++">
import std;
#include <iostream>
#include <memory>
 
enum class ProductId {MINE, YOURS};
 
// defines the interface of objects the factory method creates.
Line 45 ⟶ 44:
public:
void print() {
std::cout << println("this=" << this << "{} print MINE\n", this);
}
};
Line 53 ⟶ 52:
public:
void print() {
std::cout << println("this=" << this << "{} print YOURS\n", this);
}
};