===== Reference ===== * design pattern matrix * http://www.netobjectives.com/download/dpmatrix.pdf * http://uml.org.cn/sjms/pdf/dpmatrix.pdf * http://sourcemaking.com/design_patterns# CPlusPlus * [[Livre]] : http://rzr.online.fr/isbn/2841773507 # Design patterns Tête la première (Broché) fr * https://github.com/jwasham/coding-interview-university#dont-feel-you-arent-smart-enough# LearN * https://www.fluentcpp.com/2020/12/18/on-design-patterns-in-cpp/# ===== TEMPLATES ===== // file:///~/singleton.hpp template class Singleton { public: static T* get() { if ( instance == 0 ) instance = new T; return instance; } protected: Singleton() { } ~Singleton() { } private: static T* instance; }; template T* Singleton::instance = NULL; // here the tricky part // file:///~/main.cpp #include using namespace std; #include "singleton.hpp" int main() { Singleton::get(); return EXIT_SUCCESS; } Note: [[Microsoft]] msvs allows default types , not GCC so avoid those : template //... ===== TEMPLATES & DESIGN PATTERN ===== what do u think of this weird code : /// Design Pattern (with templates) template class VisitorAble { public: virtual int visit(T & in_data)=0; }; template class AcceptAble { public: virtual int accept(T & in_visitor) { in_visitor.visit( *this ); } }; class Visitor : public Visitor { public: ... visit ... }; class Data : public AcceptAble > {}; // recursive template ? ===== MORE ===== @TaG: [[Design]] [[Pattern]] [[C++]] [[CPlusPlus]] [[templates]] [[DP]] [[pointers]] [[OOP]] [[STL]] [[auto_ptr]] [[boost]]