Created
September 24, 2019 14:05
-
-
Save thedeemon/e743410393045ad242465ec9b24c4023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ILogger { | |
void log(string msg); | |
} | |
class BoringLogger : ILogger { | |
overrride void log(string msg) {...} | |
} | |
class ColorfulLogger : ILogger { | |
overrride void log(string msg) {...} | |
} | |
void writef(T...)(ILogger logger, T params) { | |
// all generic code of turning different types of params to string | |
// then pass this string to logger | |
} | |
main() { | |
auto logger1 = new BoringLogger; | |
auto logger2 = new ColorfulLogger; | |
logger1.writef(1, "hi", 3.3); | |
logger2.writef(1, "hi", 3.3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment