Policy based design and best practices - C++
问题 struct InkPen { void Write() { this->WriteImplementation(); } void WriteImplementation() { std::cout << "Writing using a inkpen" << std::endl; } }; struct BoldPen { void Write() { std::cout << "Writing using a boldpen" << std::endl; } }; template<class PenType> class Writer : public PenType { public: void StartWriting() { PenType::Write(); } }; int main() { Writer<InkPen> writer; writer.StartWriting(); Writer<BoldPen> writer1; writer1.StartWriting(); return 0; } I wrote the above code as part