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.
No edit summary
Tags: Mobile edit Mobile web edit
Line 29:
This C++14 implementation is based on the pre C++98 implementation in the 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);
}
};
 
// )implements the Product interface.
class ConcreteProductYOURS: public Product {
public:
void print() {
std::cout << println("this=" << this << "{} print YOURS\n", this);
}
};