C++ runtime polymorphism과 constructor injection, property injection
enum class를 이용한 runtime polymorphism #include #include struct FileLogger { void log_transfer(long from, long to, double amount) { --snip-- printf("[file] %ld,%ld,%f\n", from, to, amount); } }; struct ConsoleLogger { void log_transfer(long from, long to, double amount) { printf("[cons] %ld -> %ld: %f\n", from, to, amount); } }; enum class LoggerType { Console, File }; struct Bank { Bank() : type ..
2022. 2. 28.