From 67bb27e9f5beec4d8ca0a6c29f045d5f23d6f40f Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sun, 28 Feb 2021 17:25:57 +0700 Subject: [lang] Reorganize language learning archive --- lang/cpptour/enumcls.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lang/cpptour/enumcls.cc (limited to 'lang/cpptour/enumcls.cc') diff --git a/lang/cpptour/enumcls.cc b/lang/cpptour/enumcls.cc new file mode 100644 index 0000000..2340f65 --- /dev/null +++ b/lang/cpptour/enumcls.cc @@ -0,0 +1,28 @@ +#include + +using namespace std; + +enum class Color { red, blue, green }; +enum class TraficLight { green, yellow, red }; + +TraficLight& operator++ (TraficLight& t) +{ + switch (t) + { + case TraficLight::green: + return t = TraficLight::yellow; + case TraficLight::yellow: + return t = TraficLight::red; + case TraficLight::red: + return t = TraficLight::green; + } +} + +int +main () +{ + Color col = Color::red; + TraficLight light = TraficLight::red; + TraficLight nxt = ++light; + // ugh now we test if it compiles? just wanna build some muscle memory +} -- cgit 1.4.1